diff --git a/examples/llama.android/app/src/main/java/com/example/llama/MainActivity.kt b/examples/llama.android/app/src/main/java/com/example/llama/MainActivity.kt index 74313fb0ac..dad1d0de58 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/MainActivity.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/MainActivity.kt @@ -201,7 +201,7 @@ fun AppContent( else TopBarConfig.Default( title = "Pick your model", navigationIcon = NavigationIcon.Menu { - modelSelectionViewModel.resetSelection() + modelSelectionViewModel.resetPreselection() openDrawer() } ), @@ -231,10 +231,11 @@ fun AppContent( ), runAction = BottomBarConfig.ModelSelection.RunActionConfig( preselection = preselection, - onClickRun = { preselection -> - if (modelSelectionViewModel.selectModel(preselection)) { - navigationActions.navigateToModelLoading() + onClickRun = { + if (modelSelectionViewModel.selectModel(it)) { modelSelectionViewModel.toggleSearchState(false) + modelSelectionViewModel.resetPreselection() + navigationActions.navigateToModelLoading() } } ) diff --git a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelSelectionScreen.kt b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelSelectionScreen.kt index abfabdffce..9282e09f61 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelSelectionScreen.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/ui/screens/ModelSelectionScreen.kt @@ -155,7 +155,7 @@ fun ModelSelectionScreen( if (selected) { toggleSearchFocusAndIme(false) } else { - viewModel.resetSelection() + viewModel.resetPreselection() toggleSearchFocusAndIme(true) } }, @@ -185,7 +185,7 @@ fun ModelSelectionScreen( model = model, isSelected = if (model == preselection?.modelInfo) true else null, onSelected = { selected -> - if (!selected) viewModel.resetSelection() + if (!selected) viewModel.resetPreselection() }, isExpanded = model == preselection?.modelInfo, onExpanded = { expanded -> diff --git a/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelSelectionViewModel.kt b/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelSelectionViewModel.kt index 70b5e1cfa1..7c4bea1b49 100644 --- a/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelSelectionViewModel.kt +++ b/examples/llama.android/app/src/main/java/com/example/llama/viewmodel/ModelSelectionViewModel.kt @@ -45,7 +45,7 @@ class ModelSelectionViewModel @Inject constructor( fun toggleSearchState(active: Boolean) { _isSearchActive.value = active if (active) { - resetSelection() + resetPreselection() } else { searchFieldState.clearText() } @@ -163,6 +163,14 @@ class ModelSelectionViewModel @Inject constructor( _showRamWarning.value = false } + /** + * Reset preselected model to none (before navigating away) + */ + fun resetPreselection() { + _preselectedModel.value = null + _showRamWarning.value = false + } + /** * Select the currently pre-selected model * @@ -181,6 +189,13 @@ class ModelSelectionViewModel @Inject constructor( else -> false } + /** + * Dismiss the RAM warnings + */ + fun dismissRamWarning() { + _showRamWarning.value = false + } + /** * Acknowledge RAM warnings and confirm currently pre-selected model * @@ -195,27 +210,12 @@ class ModelSelectionViewModel @Inject constructor( false } - /** - * Dismiss the RAM warnings - */ - fun dismissRamWarning() { - _showRamWarning.value = false - } - - /** - * Reset selected model to none (before navigating away) - */ - fun resetSelection() { - _preselectedModel.value = null - _showRamWarning.value = false - } - /** * Handle back press from both back button and top bar */ fun onBackPressed() { if (_preselectedModel.value != null) { - resetSelection() + resetPreselection() } }