Use lifecycleScope directly
This commit is contained in:
@@ -24,6 +24,7 @@ import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.setPadding
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import eu.kanade.tachiyomi.R
|
||||
@@ -664,42 +665,42 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
delay(250)
|
||||
setOrientation(it)
|
||||
}
|
||||
.launchIn(scope)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.readerTheme().asFlow()
|
||||
.drop(1) // We only care about updates
|
||||
.onEach { recreate() }
|
||||
.launchIn(scope)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.showPageNumber().asFlow()
|
||||
.onEach { setPageNumberVisibility(it) }
|
||||
.launchIn(scope)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.trueColor().asFlow()
|
||||
.onEach { setTrueColor(it) }
|
||||
.launchIn(scope)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
preferences.cutoutShort().asFlow()
|
||||
.onEach { setCutoutShort(it) }
|
||||
.launchIn(scope)
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
preferences.keepScreenOn().asFlow()
|
||||
.onEach { setKeepScreenOn(it) }
|
||||
.launchIn(scope)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.customBrightness().asFlow()
|
||||
.onEach { setCustomBrightness(it) }
|
||||
.launchIn(scope)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.colorFilter().asFlow()
|
||||
.onEach { setColorFilter(it) }
|
||||
.launchIn(scope)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.colorFilterMode().asFlow()
|
||||
.onEach { setColorFilter(preferences.colorFilter().get()) }
|
||||
.launchIn(scope)
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -777,7 +778,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
preferences.customBrightnessValue().asFlow()
|
||||
.sample(100)
|
||||
.onEach { setCustomBrightnessValue(it) }
|
||||
.launchIn(scope)
|
||||
.launchIn(lifecycleScope)
|
||||
} else {
|
||||
setCustomBrightnessValue(0)
|
||||
}
|
||||
@@ -791,7 +792,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
preferences.colorFilterValue().asFlow()
|
||||
.sample(100)
|
||||
.onEach { setColorFilterValue(it) }
|
||||
.launchIn(scope)
|
||||
.launchIn(lifecycleScope)
|
||||
} else {
|
||||
binding.colorOverlay.isVisible = false
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.reader
|
||||
import android.view.ViewGroup
|
||||
import android.widget.SeekBar
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
@@ -32,15 +33,15 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
|
||||
preferences.colorFilter().asFlow()
|
||||
.onEach { setColorFilter(it) }
|
||||
.launchIn(activity.scope)
|
||||
.launchIn(activity.lifecycleScope)
|
||||
|
||||
preferences.colorFilterMode().asFlow()
|
||||
.onEach { setColorFilter(preferences.colorFilter().get()) }
|
||||
.launchIn(activity.scope)
|
||||
.launchIn(activity.lifecycleScope)
|
||||
|
||||
preferences.customBrightness().asFlow()
|
||||
.onEach { setCustomBrightness(it) }
|
||||
.launchIn(activity.scope)
|
||||
.launchIn(activity.lifecycleScope)
|
||||
|
||||
// Get color and update values
|
||||
val color = preferences.colorFilterValue().get()
|
||||
@@ -178,7 +179,7 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
preferences.customBrightnessValue().asFlow()
|
||||
.sample(100)
|
||||
.onEach { setCustomBrightnessValue(it) }
|
||||
.launchIn(activity.scope)
|
||||
.launchIn(activity.lifecycleScope)
|
||||
} else {
|
||||
setCustomBrightnessValue(0, true)
|
||||
}
|
||||
@@ -206,7 +207,7 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
preferences.colorFilterValue().asFlow()
|
||||
.sample(100)
|
||||
.onEach { setColorFilterValue(it) }
|
||||
.launchIn(activity.scope)
|
||||
.launchIn(activity.lifecycleScope)
|
||||
}
|
||||
setColorFilterSeekBar(enabled)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user