diff --git a/app/build.gradle b/app/build.gradle index 026012da1..564e4cdb3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -232,7 +232,6 @@ dependencies { // RxBindings final rxbindings_version = '1.0.1' - implementation "com.jakewharton.rxbinding:rxbinding-appcompat-v7-kotlin:$rxbindings_version" implementation "com.jakewharton.rxbinding:rxbinding-support-v4-kotlin:$rxbindings_version" // FlowBinding diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt index 6cc1cdeb7..dbd99e95e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackSearchDialog.kt @@ -102,7 +102,7 @@ class TrackSearchDialog : DialogController { override fun onAttach(view: View) { super.onAttach(view) - dialogView!!.track_search.textChanges(false) + dialogView!!.track_search.textChanges() .debounce(TimeUnit.SECONDS.toMillis(1)) .map { it.toString() } .filter { it.isNotBlank() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt index 794fca33f..f2e791c41 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt @@ -16,7 +16,6 @@ import androidx.recyclerview.widget.RecyclerView import com.afollestad.materialdialogs.MaterialDialog import com.f2prateek.rx.preferences.Preference import com.google.android.material.snackbar.Snackbar -import com.jakewharton.rxbinding.support.v7.widget.queryTextChangeEvents import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.R @@ -41,10 +40,14 @@ import eu.kanade.tachiyomi.util.view.snack import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.widget.AutofitRecyclerView import eu.kanade.tachiyomi.widget.EmptyView -import java.util.concurrent.TimeUnit -import rx.Observable +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach +import reactivecircus.flowbinding.appcompat.QueryTextEvent +import reactivecircus.flowbinding.appcompat.queryTextEvents import rx.Subscription -import rx.android.schedulers.AndroidSchedulers import timber.log.Timber import uy.kohesive.injekt.injectLazy @@ -84,11 +87,6 @@ open class BrowseSourceController(bundle: Bundle) : */ private var recycler: RecyclerView? = null - /** - * Subscription for the search view. - */ - private var searchViewSubscription: Subscription? = null - /** * Subscription for the number of manga per row. */ @@ -99,6 +97,8 @@ open class BrowseSourceController(bundle: Bundle) : */ private var progressItem: ProgressItem? = null + private val uiScope = CoroutineScope(Dispatchers.Main) + private lateinit var binding: SourceControllerBinding init { @@ -160,8 +160,6 @@ open class BrowseSourceController(bundle: Bundle) : override fun onDestroyView(view: View) { numColumnsSubscription?.unsubscribe() numColumnsSubscription = null - searchViewSubscription?.unsubscribe() - searchViewSubscription = null adapter = null snack = null recycler = null @@ -244,20 +242,11 @@ open class BrowseSourceController(bundle: Bundle) : searchView.clearFocus() } - val searchEventsObservable = searchView.queryTextChangeEvents() - .skip(1) - .filter { router.backstack.lastOrNull()?.controller() == this@BrowseSourceController } - .share() - val writingObservable = searchEventsObservable - .filter { !it.isSubmitted } - .debounce(1250, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()) - val submitObservable = searchEventsObservable - .filter { it.isSubmitted } - - searchViewSubscription?.unsubscribe() - searchViewSubscription = Observable.merge(writingObservable, submitObservable) - .map { it.queryText().toString() } - .subscribeUntilDestroy { searchWithQuery(it) } + searchView.queryTextEvents() + .filter { router.backstack.lastOrNull()?.controller() == this@BrowseSourceController } + .filter { it is QueryTextEvent.QuerySubmitted } + .onEach { searchWithQuery(it.queryText.toString()) } + .launchIn(uiScope) searchItem.fixExpand( onExpand = { invalidateMenuOnExpand() },