mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-28 09:15:12 +03:00
Fix catalogue search focus automatically being removed (#2396)
Fix catalogue search focus automatically being removed
This commit is contained in:
parent
57595988f5
commit
6b5742c1ff
2 changed files with 9 additions and 12 deletions
|
@ -89,15 +89,16 @@ abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateContr
|
|||
* This method should be removed when fixed upstream.
|
||||
* Issue link: https://issuetracker.google.com/issues/37657375
|
||||
*/
|
||||
fun MenuItem.fixExpand() {
|
||||
fun MenuItem.fixExpand(onExpand: ((MenuItem) -> Boolean)? = null, onCollapse: ((MenuItem) -> Boolean)? = null) {
|
||||
setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
||||
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
||||
return true
|
||||
return onExpand?.invoke(item) ?: true
|
||||
}
|
||||
|
||||
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
|
||||
activity?.invalidateOptionsMenu()
|
||||
return true
|
||||
|
||||
return onCollapse?.invoke(item) ?: true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import kotlinx.android.synthetic.main.main_activity.*
|
|||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.subscriptions.Subscriptions
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
@ -228,6 +227,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
|||
|
||||
val searchEventsObservable = searchView.queryTextChangeEvents()
|
||||
.skip(1)
|
||||
.filter { router.backstack.lastOrNull()?.controller() == this@BrowseCatalogueController }
|
||||
.share()
|
||||
val writingObservable = searchEventsObservable
|
||||
.filter { !it.isSubmitted }
|
||||
|
@ -238,11 +238,12 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
|||
searchViewSubscription?.unsubscribe()
|
||||
searchViewSubscription = Observable.merge(writingObservable, submitObservable)
|
||||
.map { it.queryText().toString() }
|
||||
.distinctUntilChanged()
|
||||
.subscribeUntilDestroy { searchWithQuery(it) }
|
||||
|
||||
untilDestroySubscriptions.add(
|
||||
Subscriptions.create { if (isActionViewExpanded) collapseActionView() })
|
||||
fixExpand(onCollapse = {
|
||||
searchWithQuery("")
|
||||
true
|
||||
})
|
||||
}
|
||||
|
||||
// Setup filters button
|
||||
|
@ -310,11 +311,6 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
|||
if (presenter.query == newQuery)
|
||||
return
|
||||
|
||||
// FIXME dirty fix to restore the toolbar buttons after closing search mode.
|
||||
if (newQuery == "") {
|
||||
activity?.invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
showProgressBar()
|
||||
adapter?.clear()
|
||||
|
||||
|
|
Loading…
Reference in a new issue