Migrate More screen to Compose (#6990)

This commit is contained in:
arkon
2022-04-23 15:51:50 -04:00
committed by GitHub
parent 8933b41937
commit c25cffafc6
7 changed files with 341 additions and 175 deletions
@@ -1,6 +1,8 @@
package eu.kanade.tachiyomi.ui.base.presenter
import android.os.Bundle
import com.fredporciuncula.flow.preferences.Preference
import eu.kanade.core.prefs.PreferenceMutableState
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel
@@ -10,7 +12,7 @@ import rx.Observable
open class BasePresenter<V> : RxPresenter<V>() {
lateinit var presenterScope: CoroutineScope
var presenterScope: CoroutineScope = MainScope()
/**
* Query from the view where applicable
@@ -20,7 +22,6 @@ open class BasePresenter<V> : RxPresenter<V>() {
override fun onCreate(savedState: Bundle?) {
try {
super.onCreate(savedState)
presenterScope = MainScope()
} catch (e: NullPointerException) {
// Swallow this error. This should be fixed in the library but since it's not critical
// (only used by restartables) it should be enough. It saves me a fork.
@@ -38,6 +39,8 @@ open class BasePresenter<V> : RxPresenter<V>() {
return super.getView()
}
fun <T> Preference<T>.asState() = PreferenceMutableState(this, presenterScope)
/**
* Subscribes an observable with [deliverFirst] and adds it to the presenter's lifecycle
* subscription list.