From d2d503b2f52dc1012935a2f08c108af1c58d9884 Mon Sep 17 00:00:00 2001 From: HapeLee <1321903405@qq.com> Date: Sun, 12 Oct 2025 21:56:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E7=95=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kazusa/ui/book/cache/CacheAdapter.kt | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/io/legato/kazusa/ui/book/cache/CacheAdapter.kt b/app/src/main/java/io/legato/kazusa/ui/book/cache/CacheAdapter.kt index 4ec1c9d01..a45e50af8 100644 --- a/app/src/main/java/io/legato/kazusa/ui/book/cache/CacheAdapter.kt +++ b/app/src/main/java/io/legato/kazusa/ui/book/cache/CacheAdapter.kt @@ -46,24 +46,24 @@ class CacheAdapter(context: Context, private val callBack: CallBack) : payloads: MutableList ) { binding.run { + progressDownload.gone() + progressExport.gone() + tvMsg.gone() + tvDownload.text = "" + ivDownload.icon = null + if (payloads.isEmpty()) { tvName.text = item.name tvAuthor.text = context.getString(R.string.author_show, item.getRealAuthor()) if (item.isLocal) { tvDownload.setText(R.string.local_book) - progressDownload.gone() } else { val cs = callBack.cacheChapters[item.bookUrl] - if (cs == null) { - tvDownload.setText(R.string.loading) + tvDownload.text = if (cs == null) { + context.getString(R.string.loading) } else { - tvDownload.text = - context.getString( - R.string.download_count, - cs.size, - item.totalChapterNum - ) + context.getString(R.string.download_count, cs.size, item.totalChapterNum) } } } else { @@ -71,21 +71,12 @@ class CacheAdapter(context: Context, private val callBack: CallBack) : tvDownload.setText(R.string.local_book) } else { val cacheSize = callBack.cacheChapters[item.bookUrl]?.size ?: 0 + tvDownload.text = context.getString(R.string.download_count, cacheSize, item.totalChapterNum) val cacheTask = CacheBook.cacheBookMap[item.bookUrl] - tvDownload.text = - context.getString(R.string.download_count, cacheSize, item.totalChapterNum) - if (cacheTask != null && !cacheTask.isStop()) { - val progress = if (item.totalChapterNum > 0) { - (cacheSize * 100 / item.totalChapterNum) - } else { - 0 - } - tvMsg.gone() + val progress = if (item.totalChapterNum > 0) cacheSize * 100 / item.totalChapterNum else 0 progressDownload.progress = progress progressDownload.visible() - } else { - progressDownload.gone() } } } @@ -94,6 +85,7 @@ class CacheAdapter(context: Context, private val callBack: CallBack) : } } + override fun registerListener(holder: ItemViewHolder, binding: ItemDownloadBinding) { binding.run { ivDownload.setOnClickListener { @@ -121,7 +113,7 @@ class CacheAdapter(context: Context, private val callBack: CallBack) : CacheBook.remove(context, book.bookUrl) Handler(Looper.getMainLooper()).postDelayed({ callBack.deleteDownload(book) - }, 500) + }, 10) } else { callBack.deleteDownload(book) } @@ -152,22 +144,21 @@ class CacheAdapter(context: Context, private val callBack: CallBack) : } private fun upExportInfo(msgView: TextView, progressView: ProgressBar, book: Book) { + msgView.gone() + progressView.gone() + val msg = callBack.exportMsg(book.bookUrl) if (msg != null) { msgView.text = msg msgView.visible() - progressView.gone() return } - msgView.gone() val progress = callBack.exportProgress(book.bookUrl) if (progress != null) { progressView.max = book.totalChapterNum progressView.progress = progress progressView.visible() - return } - progressView.gone() } interface CallBack {