|
|
@ -13,6 +13,7 @@ import androidx.activity.result.contract.ActivityResultContracts |
|
|
|
import androidx.core.view.get |
|
|
|
import androidx.core.view.get |
|
|
|
import androidx.core.view.isVisible |
|
|
|
import androidx.core.view.isVisible |
|
|
|
import androidx.core.view.size |
|
|
|
import androidx.core.view.size |
|
|
|
|
|
|
|
import androidx.lifecycle.lifecycleScope |
|
|
|
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener |
|
|
|
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener |
|
|
|
import io.legado.app.BuildConfig |
|
|
|
import io.legado.app.BuildConfig |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
@ -108,7 +109,7 @@ class ReadBookActivity : ReadBookBaseActivity(), |
|
|
|
TextActionMenu(this, this) |
|
|
|
TextActionMenu(this, this) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override val scope: CoroutineScope get() = this |
|
|
|
override val scope: CoroutineScope get() = lifecycleScope |
|
|
|
override val isInitFinish: Boolean get() = viewModel.isInitFinish |
|
|
|
override val isInitFinish: Boolean get() = viewModel.isInitFinish |
|
|
|
override val isScroll: Boolean get() = binding.readView.isScroll |
|
|
|
override val isScroll: Boolean get() = binding.readView.isScroll |
|
|
|
private val mHandler = Handler(Looper.getMainLooper()) |
|
|
|
private val mHandler = Handler(Looper.getMainLooper()) |
|
|
@ -591,7 +592,7 @@ class ReadBookActivity : ReadBookBaseActivity(), |
|
|
|
resetPageOffset: Boolean, |
|
|
|
resetPageOffset: Boolean, |
|
|
|
success: (() -> Unit)? |
|
|
|
success: (() -> Unit)? |
|
|
|
) { |
|
|
|
) { |
|
|
|
launch { |
|
|
|
lifecycleScope.launch { |
|
|
|
autoPageProgress = 0 |
|
|
|
autoPageProgress = 0 |
|
|
|
binding.readView.upContent(relativePosition, resetPageOffset) |
|
|
|
binding.readView.upContent(relativePosition, resetPageOffset) |
|
|
|
binding.readMenu.setSeekPage(ReadBook.durPageIndex()) |
|
|
|
binding.readMenu.setSeekPage(ReadBook.durPageIndex()) |
|
|
@ -604,13 +605,13 @@ class ReadBookActivity : ReadBookBaseActivity(), |
|
|
|
* 更新视图 |
|
|
|
* 更新视图 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
override fun upView() { |
|
|
|
override fun upView() { |
|
|
|
launch { |
|
|
|
lifecycleScope.launch { |
|
|
|
binding.readMenu.upBookView() |
|
|
|
binding.readMenu.upBookView() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun upPageAnim() { |
|
|
|
override fun upPageAnim() { |
|
|
|
launch { |
|
|
|
lifecycleScope.launch { |
|
|
|
binding.readView.upPageAnim() |
|
|
|
binding.readView.upPageAnim() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -620,7 +621,7 @@ class ReadBookActivity : ReadBookBaseActivity(), |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
override fun pageChanged() { |
|
|
|
override fun pageChanged() { |
|
|
|
autoPageProgress = 0 |
|
|
|
autoPageProgress = 0 |
|
|
|
launch { |
|
|
|
lifecycleScope.launch { |
|
|
|
binding.readMenu.setSeekPage(ReadBook.durPageIndex()) |
|
|
|
binding.readMenu.setSeekPage(ReadBook.durPageIndex()) |
|
|
|
} |
|
|
|
} |
|
|
|
mHandler.postDelayed(backupRunnable, 600000) |
|
|
|
mHandler.postDelayed(backupRunnable, 600000) |
|
|
@ -846,7 +847,7 @@ class ReadBookActivity : ReadBookBaseActivity(), |
|
|
|
viewModel.searchContentQuery |
|
|
|
viewModel.searchContentQuery |
|
|
|
) |
|
|
|
) |
|
|
|
ReadBook.skipToPage(positions[0]) { |
|
|
|
ReadBook.skipToPage(positions[0]) { |
|
|
|
launch { |
|
|
|
lifecycleScope.launch { |
|
|
|
binding.readView.curPage.selectStartMoveIndex(0, positions[1], positions[2]) |
|
|
|
binding.readView.curPage.selectStartMoveIndex(0, positions[1], positions[2]) |
|
|
|
delay(20L) |
|
|
|
delay(20L) |
|
|
|
when (positions[3]) { |
|
|
|
when (positions[3]) { |
|
|
@ -936,7 +937,7 @@ class ReadBookActivity : ReadBookBaseActivity(), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
observeEventSticky<Int>(EventBus.TTS_PROGRESS) { chapterStart -> |
|
|
|
observeEventSticky<Int>(EventBus.TTS_PROGRESS) { chapterStart -> |
|
|
|
launch(IO) { |
|
|
|
lifecycleScope.launch(IO) { |
|
|
|
if (BaseReadAloudService.isPlay()) { |
|
|
|
if (BaseReadAloudService.isPlay()) { |
|
|
|
ReadBook.curTextChapter?.let { textChapter -> |
|
|
|
ReadBook.curTextChapter?.let { textChapter -> |
|
|
|
val pageStart = chapterStart - ReadBook.durChapterPos |
|
|
|
val pageStart = chapterStart - ReadBook.durChapterPos |
|
|
|