adding a helper function to avoid duplication

This commit is contained in:
tibbi 2023-01-06 17:49:54 +01:00
parent 7a558f68f5
commit c5a880b5f1
1 changed files with 9 additions and 8 deletions

View File

@ -143,10 +143,7 @@ class MainActivity : SimpleActivity() {
main_menu.setupMenu() main_menu.setupMenu()
main_menu.onSearchClosedListener = { main_menu.onSearchClosedListener = {
search_holder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction { fadeOutSearch()
search_holder.beGone()
searchTextChanged("", true)
}.start()
} }
main_menu.onSearchTextChangedListener = { text -> main_menu.onSearchTextChangedListener = { text ->
@ -155,10 +152,7 @@ class MainActivity : SimpleActivity() {
search_holder.fadeIn() search_holder.fadeIn()
} }
} else { } else {
search_holder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction { fadeOutSearch()
search_holder.beGone()
searchTextChanged("", true)
}.start()
} }
searchTextChanged(text) searchTextChanged(text)
} }
@ -384,6 +378,13 @@ class MainActivity : SimpleActivity() {
} }
} }
private fun fadeOutSearch() {
search_holder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction {
search_holder.beGone()
searchTextChanged("", true)
}.start()
}
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
private fun notifyDatasetChanged() { private fun notifyDatasetChanged() {
getOrCreateConversationsAdapter().notifyDataSetChanged() getOrCreateConversationsAdapter().notifyDataSetChanged()