|
@@ -28,6 +28,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
|
|
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
|
|
import eu.kanade.tachiyomi.data.notification.Notifications
|
|
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
|
+import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
|
import eu.kanade.tachiyomi.databinding.ReaderActivityBinding
|
|
|
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
|
|
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter.SetAsCoverResult.AddToLibraryFirst
|
|
@@ -54,16 +55,13 @@ import eu.kanade.tachiyomi.util.view.visible
|
|
|
import eu.kanade.tachiyomi.widget.SimpleAnimationListener
|
|
|
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
|
|
|
import java.io.File
|
|
|
-import java.util.concurrent.TimeUnit
|
|
|
import kotlin.math.abs
|
|
|
+import kotlinx.coroutines.delay
|
|
|
import kotlinx.coroutines.flow.drop
|
|
|
import kotlinx.coroutines.flow.launchIn
|
|
|
import kotlinx.coroutines.flow.onEach
|
|
|
import kotlinx.coroutines.flow.sample
|
|
|
import nucleus.factory.RequiresPresenter
|
|
|
-import rx.Observable
|
|
|
-import rx.android.schedulers.AndroidSchedulers
|
|
|
-import rx.subscriptions.CompositeSubscription
|
|
|
import timber.log.Timber
|
|
|
import uy.kohesive.injekt.injectLazy
|
|
|
|
|
@@ -163,7 +161,6 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|
|
super.onDestroy()
|
|
|
viewer?.destroy()
|
|
|
viewer = null
|
|
|
- config?.destroy()
|
|
|
config = null
|
|
|
progressDialog?.dismiss()
|
|
|
progressDialog = null
|
|
@@ -606,22 +603,17 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|
|
*/
|
|
|
private inner class ReaderConfig {
|
|
|
|
|
|
- /**
|
|
|
- * List of subscriptions to keep while the reader is alive.
|
|
|
- */
|
|
|
- private val subscriptions = CompositeSubscription()
|
|
|
-
|
|
|
/**
|
|
|
* Initializes the reader subscriptions.
|
|
|
*/
|
|
|
init {
|
|
|
- val sharedRotation = preferences.rotation().asObservable().share()
|
|
|
- val initialRotation = sharedRotation.take(1)
|
|
|
- val rotationUpdates = sharedRotation.skip(1)
|
|
|
- .delay(250, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
|
|
-
|
|
|
- subscriptions += Observable.merge(initialRotation, rotationUpdates)
|
|
|
- .subscribe { setOrientation(it) }
|
|
|
+ preferences.rotation().asImmediateFlow { setOrientation(it) }
|
|
|
+ .drop(1)
|
|
|
+ .onEach {
|
|
|
+ delay(250)
|
|
|
+ setOrientation(it)
|
|
|
+ }
|
|
|
+ .launchIn(scope)
|
|
|
|
|
|
preferences.readerTheme().asFlow()
|
|
|
.drop(1) // We only care about updates
|
|
@@ -659,13 +651,6 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|
|
.launchIn(scope)
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Called when the reader is being destroyed. It cleans up all the subscriptions.
|
|
|
- */
|
|
|
- fun destroy() {
|
|
|
- subscriptions.unsubscribe()
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Forces the user preferred [orientation] on the activity.
|
|
|
*/
|