This commit is contained in:
Horis
2025-03-21 16:26:51 +08:00
parent ab8f448ffe
commit 03d05f5df5
2 changed files with 8 additions and 11 deletions
@@ -118,7 +118,11 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
private var justInitData: Boolean = false private var justInitData: Boolean = false
private var syncDialog: AlertDialog? = null private var syncDialog: AlertDialog? = null
private lateinit var mScrollTimer: ScrollTimer private val mScrollTimer by lazy {
ScrollTimer(lifecycleScope, this).apply {
setSpeed(AppConfig.mangaAutoPageSpeed)
}
}
private var enableAutoPageScroll = false private var enableAutoPageScroll = false
private var enableAutoScroll = false private var enableAutoScroll = false
private val mLinearInterpolator by lazy { private val mLinearInterpolator by lazy {
@@ -180,10 +184,6 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
mMangaFooterConfig = mMangaFooterConfig =
GSON.fromJsonObject<MangaFooterConfig>(AppConfig.mangaFooterConfig).getOrNull() GSON.fromJsonObject<MangaFooterConfig>(AppConfig.mangaFooterConfig).getOrNull()
?: MangaFooterConfig() ?: MangaFooterConfig()
mScrollTimer = ScrollTimer(this).apply {
setSpeed(AppConfig.mangaAutoPageSpeed)
callback = this@ReadMangaActivity
}
} }
override fun observeLiveBus() { override fun observeLiveBus() {
@@ -1,21 +1,18 @@
package io.legado.app.ui.book.manga.recyclerview package io.legado.app.ui.book.manga.recyclerview
import androidx.lifecycle.LifecycleOwner import kotlinx.coroutines.CoroutineScope
import androidx.lifecycle.lifecycleScope
import io.legado.app.model.ReadManga
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class ScrollTimer( class ScrollTimer(
lifecycleOwner: LifecycleOwner, private val coroutineScope: CoroutineScope,
private val callback: ScrollCallback
) { ) {
private val coroutineScope = lifecycleOwner.lifecycleScope
private var job: Job? = null private var job: Job? = null
private var delayMs: Long = 20L private var delayMs: Long = 20L
private var distance = 1 private var distance = 1
lateinit var callback: ScrollCallback
var isEnabled: Boolean = false var isEnabled: Boolean = false
set(value) { set(value) {
if (field != value) { if (field != value) {