diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 5070a74dc..1ea320505 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -49,6 +49,10 @@ object BookHelp { file.writeText(content) } + fun getChapterCount(book: Book): Int { + return FileHelp.getFolder(getBookFolder(book)).list()?.size ?: 0 + } + fun hasContent(book: Book, bookChapter: BookChapter): Boolean { val filePath = getChapterPath(book, bookChapter) runCatching { diff --git a/app/src/main/java/io/legado/app/ui/download/DownloadAdapter.kt b/app/src/main/java/io/legado/app/ui/download/DownloadAdapter.kt index c6825041f..25b1b5b35 100644 --- a/app/src/main/java/io/legado/app/ui/download/DownloadAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/download/DownloadAdapter.kt @@ -1,10 +1,12 @@ package io.legado.app.ui.download import android.content.Context +import android.view.View import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.Book +import io.legado.app.help.BookHelp import kotlinx.android.synthetic.main.item_download.view.* @@ -13,9 +15,22 @@ class DownloadAdapter(context: Context) : override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList) { with(holder.itemView) { - tv_name.text = item.name - tv_author.text = item.author + if (payloads.isEmpty()) { + tv_name.text = item.name + tv_author.text = item.author + upDownloadCount(this, item) + } else { + upDownloadCount(this, item) + } } } + private fun upDownloadCount(view: View, book: Book) { + view.tv_download.text = context.getString( + R.string.download_count, + BookHelp.getChapterCount(book), + book.totalChapterNum + ) + } + } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt index c0d19851f..144fa4e19 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt @@ -9,7 +9,6 @@ import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.data.entities.BookSource import io.legado.app.help.coroutine.Coroutine -import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.utils.ACache import io.legado.app.utils.gone @@ -29,7 +28,6 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca override fun convert(holder: ItemViewHolder, item: BookSource, payloads: MutableList) { with(holder.itemView) { if (payloads.isEmpty()) { - ATH.applyBackgroundTint(ll_title) tv_name.text = item.bookSourceName ll_title.onClick { val oldEx = exIndex diff --git a/app/src/main/res/layout/item_find_book.xml b/app/src/main/res/layout/item_find_book.xml index 266e69e8d..8a95ed1e2 100644 --- a/app/src/main/res/layout/item_find_book.xml +++ b/app/src/main/res/layout/item_find_book.xml @@ -18,11 +18,9 @@ android:paddingTop="6dp" android:paddingBottom="6dp" android:layout_margin="4dp" - android:background="@color/background" - android:elevation="3dp" + android:background="@color/btn_bg_press" android:orientation="horizontal" - android:gravity="center_vertical" - tools:ignore="UseCompoundDrawables"> + android:gravity="center_vertical"> 开始下载 取消下载 暂无任务 + 已下载 %d/%d 导入选择书籍 更新和搜索线程数,如感觉卡顿请减小线程数,量力而行 切换图标