已下载章节添加更明显的标记

pull/341/head
gedoor 4 years ago
parent dcce2d864c
commit cb64d0973e
  1. 11
      app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt
  2. 31
      app/src/main/res/layout/item_chapter_list.xml

@ -1,7 +1,7 @@
package io.legado.app.ui.book.chapterlist
import android.content.Context
import android.widget.TextView
import android.view.View
import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter
@ -33,12 +33,12 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
tv_tag.visible()
}
upHasCache(
tv_chapter_name,
this,
cacheFileNames.contains(BookHelp.formatChapterName(item))
)
} else {
upHasCache(
tv_chapter_name,
this,
cacheFileNames.contains(BookHelp.formatChapterName(item))
)
}
@ -53,8 +53,9 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
}
}
private fun upHasCache(textView: TextView, contains: Boolean) {
textView.paint.isFakeBoldText = contains
private fun upHasCache(itemView: View, contains: Boolean) = itemView.apply {
tv_chapter_name.paint.isFakeBoldText = contains
iv_checked.visible(contains)
}
interface Callback {

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -8,16 +9,34 @@
<TextView
android:id="@+id/tv_chapter_name"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:singleLine="true" />
android:singleLine="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/iv_checked" />
<TextView
android:id="@+id/tv_tag"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="12sp"
android:visibility="gone"
android:singleLine="true" />
android:singleLine="true"
app:layout_constraintTop_toBottomOf="@+id/tv_chapter_name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/iv_checked" />
</LinearLayout>
<ImageView
android:id="@+id/iv_checked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_check"
android:visibility="invisible"
android:contentDescription="@string/success"
app:tint="@color/primaryText"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save