优化目录

pull/346/head
gedoor 4 years ago
parent c0cad75f9f
commit f65f553d83
  1. 25
      app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt
  2. 10
      app/src/main/res/drawable/ic_outline_cloud_24.xml
  3. 2
      app/src/main/res/layout/item_chapter_list.xml

@ -21,8 +21,10 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList<Any>) {
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 {

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,6c2.62,0 4.88,1.86 5.39,4.43l0.3,1.5 1.53,0.11c1.56,0.1 2.78,1.41 2.78,2.96 0,1.65 -1.35,3 -3,3H6c-2.21,0 -4,-1.79 -4,-4 0,-2.05 1.53,-3.76 3.56,-3.97l1.07,-0.11 0.5,-0.95C8.08,7.14 9.94,6 12,6m0,-2C9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96C18.67,6.59 15.64,4 12,4z" />
</vector>

@ -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" />

Loading…
Cancel
Save