目录菜单的下载按钮无法触发

This commit is contained in:
HapeLee committed 2025-10-12 22:06:05 +08:00
1 parent d2d503b2f5
commit 0c3ec44a9a
1 file changed
+3 -7
@@ -221,7 +221,7 @@ class TocActivity : VMBaseActivity<ActivityChapterListBinding, TocViewModel>(),
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
fun showDownloadDialog() { fun showDownloadDialog() {
ReadBook.book?.let { book -> (viewModel.bookData.value ?: ReadBook.book)?.let { book ->
alert(titleResource = R.string.offline_cache) { alert(titleResource = R.string.offline_cache) {
val alertBinding = DialogDownloadChoiceBinding.inflate(layoutInflater).apply { val alertBinding = DialogDownloadChoiceBinding.inflate(layoutInflater).apply {
editStart.setText((book.durChapterIndex + 1).toString()) editStart.setText((book.durChapterIndex + 1).toString())
@@ -230,12 +230,8 @@ class TocActivity : VMBaseActivity<ActivityChapterListBinding, TocViewModel>(),
customView { alertBinding.root } customView { alertBinding.root }
okButton { okButton {
alertBinding.run { alertBinding.run {
val start = editStart.text!!.toString().let { val start = editStart.text!!.toString().toIntOrNull() ?: 0
if (it.isEmpty()) 0 else it.toInt() val end = editEnd.text!!.toString().toIntOrNull() ?: book.totalChapterNum
}
val end = editEnd.text!!.toString().let {
if (it.isEmpty()) book.totalChapterNum else it.toInt()
}
val indices = (start - 1..end - 1).toList() val indices = (start - 1..end - 1).toList()
CacheBook.start(this@TocActivity, book, indices) CacheBook.start(this@TocActivity, book, indices)
} }