Always show search view
This commit is contained in:
@@ -125,9 +125,7 @@ class MainActivity : AppCompatActivity(R.layout.main_activity) {
|
|||||||
|
|
||||||
searchView.queryHint = getString(R.string.search_recipes_hint)
|
searchView.queryHint = getString(R.string.search_recipes_hint)
|
||||||
searchView.isSubmitButtonEnabled = false
|
searchView.isSubmitButtonEnabled = false
|
||||||
|
searchView.setIconifiedByDefault(false)
|
||||||
searchView.setQuery(viewModel.lastSearchQuery, false)
|
|
||||||
searchView.isIconified = viewModel.lastSearchQuery.isNullOrBlank()
|
|
||||||
|
|
||||||
searchView.setOnCloseListener {
|
searchView.setOnCloseListener {
|
||||||
logger.v { "onClose() called" }
|
logger.v { "onClose() called" }
|
||||||
|
|||||||
@@ -32,9 +32,6 @@ class MainActivityViewModel @Inject constructor(
|
|||||||
private val _startDestination = MutableLiveData<Int>()
|
private val _startDestination = MutableLiveData<Int>()
|
||||||
val startDestination: LiveData<Int> = _startDestination
|
val startDestination: LiveData<Int> = _startDestination
|
||||||
|
|
||||||
var lastSearchQuery: String? = null
|
|
||||||
private set
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
authRepo.isAuthorizedFlow
|
authRepo.isAuthorizedFlow
|
||||||
.onEach { isAuthorized -> updateUiState { it.copy(isAuthorized = isAuthorized) } }
|
.onEach { isAuthorized -> updateUiState { it.copy(isAuthorized = isAuthorized) } }
|
||||||
@@ -60,9 +57,6 @@ class MainActivityViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun onSearchQuery(query: String?) {
|
fun onSearchQuery(query: String?) {
|
||||||
logger.v { "onSearchQuery() called with: query = $query" }
|
logger.v { "onSearchQuery() called with: query = $query" }
|
||||||
if (lastSearchQuery != query) {
|
|
||||||
lastSearchQuery = query
|
|
||||||
recipeRepo.updateNameQuery(query)
|
recipeRepo.updateNameQuery(query)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/search_recipe_action"
|
android:id="@+id/search_recipe_action"
|
||||||
android:icon="@drawable/ic_search"
|
|
||||||
android:title="@string/search_recipes_hint"
|
android:title="@string/search_recipes_hint"
|
||||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="always" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
Reference in New Issue
Block a user