Skip to content

Commit c5a880b

Browse files
committed
adding a helper function to avoid duplication
1 parent 7a558f6 commit c5a880b

File tree

1 file changed

+9
-8
lines changed
  • app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities

1 file changed

+9
-8
lines changed

app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,7 @@ class MainActivity : SimpleActivity() {
143143
main_menu.setupMenu()
144144

145145
main_menu.onSearchClosedListener = {
146-
search_holder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction {
147-
search_holder.beGone()
148-
searchTextChanged("", true)
149-
}.start()
146+
fadeOutSearch()
150147
}
151148

152149
main_menu.onSearchTextChangedListener = { text ->
@@ -155,10 +152,7 @@ class MainActivity : SimpleActivity() {
155152
search_holder.fadeIn()
156153
}
157154
} else {
158-
search_holder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction {
159-
search_holder.beGone()
160-
searchTextChanged("", true)
161-
}.start()
155+
fadeOutSearch()
162156
}
163157
searchTextChanged(text)
164158
}
@@ -384,6 +378,13 @@ class MainActivity : SimpleActivity() {
384378
}
385379
}
386380

381+
private fun fadeOutSearch() {
382+
search_holder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction {
383+
search_holder.beGone()
384+
searchTextChanged("", true)
385+
}.start()
386+
}
387+
387388
@SuppressLint("NotifyDataSetChanged")
388389
private fun notifyDatasetChanged() {
389390
getOrCreateConversationsAdapter().notifyDataSetChanged()

0 commit comments

Comments
 (0)