From f65f553d836f701ec4546ca84d032c9e9579500c Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 28 Aug 2020 14:12:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/chapterlist/ChapterListAdapter.kt | 25 ++++++++++--------- .../main/res/drawable/ic_outline_cloud_24.xml | 10 ++++++++ app/src/main/res/layout/item_chapter_list.xml | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 app/src/main/res/drawable/ic_outline_cloud_24.xml diff --git a/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt index f1043a2a4..17970bc65 100644 --- a/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt @@ -21,8 +21,10 @@ class ChapterListAdapter(context: Context, val callback: Callback) : override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList) { with(holder.itemView) { + val isDur = callback.durChapterIndex() == item.index + val cached = cacheFileNames.contains(BookHelp.formatChapterName(item)) if (payloads.isEmpty()) { - if (callback.durChapterIndex() == item.index) { + if (isDur) { tv_chapter_name.setTextColor(context.accentColor) } else { tv_chapter_name.setTextColor(context.getCompatColor(R.color.primaryText)) @@ -32,15 +34,9 @@ class ChapterListAdapter(context: Context, val callback: Callback) : tv_tag.text = item.tag tv_tag.visible() } - upHasCache( - this, - cacheFileNames.contains(BookHelp.formatChapterName(item)) - ) + upHasCache(this, isDur, cached) } else { - upHasCache( - this, - cacheFileNames.contains(BookHelp.formatChapterName(item)) - ) + upHasCache(this, isDur, cached) } } } @@ -53,9 +49,14 @@ class ChapterListAdapter(context: Context, val callback: Callback) : } } - private fun upHasCache(itemView: View, contains: Boolean) = itemView.apply { - tv_chapter_name.paint.isFakeBoldText = contains - iv_checked.visible(contains) + private fun upHasCache(itemView: View, isDur: Boolean, cached: Boolean) = itemView.apply { + tv_chapter_name.paint.isFakeBoldText = cached + iv_checked.setImageResource(R.drawable.ic_outline_cloud_24) + iv_checked.visible(!cached) + if (isDur) { + iv_checked.setImageResource(R.drawable.ic_check) + iv_checked.visible() + } } interface Callback { diff --git a/app/src/main/res/drawable/ic_outline_cloud_24.xml b/app/src/main/res/drawable/ic_outline_cloud_24.xml new file mode 100644 index 000000000..c8b092ead --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_cloud_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/item_chapter_list.xml b/app/src/main/res/layout/item_chapter_list.xml index aea6a6cfd..b0e9d4f23 100644 --- a/app/src/main/res/layout/item_chapter_list.xml +++ b/app/src/main/res/layout/item_chapter_list.xml @@ -34,7 +34,7 @@ android:src="@drawable/ic_check" android:visibility="invisible" android:contentDescription="@string/success" - app:tint="@color/primaryText" + app:tint="@color/secondaryText" app:layout_constraintTop_toTopOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintBottom_toBottomOf="parent" />