mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 22:59:18 +01: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
@ -89,15 +89,16 @@ abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateContr
|
|||||||
* This method should be removed when fixed upstream.
|
* This method should be removed when fixed upstream.
|
||||||
* Issue link: https://issuetracker.google.com/issues/37657375
|
* 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 {
|
setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
||||||
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
||||||
return true
|
return onExpand?.invoke(item) ?: true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
|
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
|
||||||
activity?.invalidateOptionsMenu()
|
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.Observable
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import rx.android.schedulers.AndroidSchedulers
|
import rx.android.schedulers.AndroidSchedulers
|
||||||
import rx.subscriptions.Subscriptions
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
@ -228,6 +227,7 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
|||||||
|
|
||||||
val searchEventsObservable = searchView.queryTextChangeEvents()
|
val searchEventsObservable = searchView.queryTextChangeEvents()
|
||||||
.skip(1)
|
.skip(1)
|
||||||
|
.filter { router.backstack.lastOrNull()?.controller() == this@BrowseCatalogueController }
|
||||||
.share()
|
.share()
|
||||||
val writingObservable = searchEventsObservable
|
val writingObservable = searchEventsObservable
|
||||||
.filter { !it.isSubmitted }
|
.filter { !it.isSubmitted }
|
||||||
@ -238,11 +238,12 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
|||||||
searchViewSubscription?.unsubscribe()
|
searchViewSubscription?.unsubscribe()
|
||||||
searchViewSubscription = Observable.merge(writingObservable, submitObservable)
|
searchViewSubscription = Observable.merge(writingObservable, submitObservable)
|
||||||
.map { it.queryText().toString() }
|
.map { it.queryText().toString() }
|
||||||
.distinctUntilChanged()
|
|
||||||
.subscribeUntilDestroy { searchWithQuery(it) }
|
.subscribeUntilDestroy { searchWithQuery(it) }
|
||||||
|
|
||||||
untilDestroySubscriptions.add(
|
fixExpand(onCollapse = {
|
||||||
Subscriptions.create { if (isActionViewExpanded) collapseActionView() })
|
searchWithQuery("")
|
||||||
|
true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup filters button
|
// Setup filters button
|
||||||
@ -310,11 +311,6 @@ open class BrowseCatalogueController(bundle: Bundle) :
|
|||||||
if (presenter.query == newQuery)
|
if (presenter.query == newQuery)
|
||||||
return
|
return
|
||||||
|
|
||||||
// FIXME dirty fix to restore the toolbar buttons after closing search mode.
|
|
||||||
if (newQuery == "") {
|
|
||||||
activity?.invalidateOptionsMenu()
|
|
||||||
}
|
|
||||||
|
|
||||||
showProgressBar()
|
showProgressBar()
|
||||||
adapter?.clear()
|
adapter?.clear()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user