feat: 优化代码

pull/98/head
kunfei 5 years ago
parent eaaf0963e0
commit 7f128b8365
  1. 7
      app/src/main/java/io/legado/app/ui/chapterlist/ChapterListAdapter.kt

@ -6,7 +6,6 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.help.BookHelp
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.getCompatColor import io.legado.app.utils.getCompatColor
import io.legado.app.utils.visible import io.legado.app.utils.visible
@ -19,6 +18,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList<Any>) { override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList<Any>) {
with(holder.itemView) { with(holder.itemView) {
if (payloads.isEmpty()) {
if (callback.durChapterIndex() == item.index) { if (callback.durChapterIndex() == item.index) {
tv_chapter_name.setTextColor(context.accentColor) tv_chapter_name.setTextColor(context.accentColor)
} else { } else {
@ -32,8 +32,9 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
this.onClick { this.onClick {
callback.openChapter(item) callback.openChapter(item)
} }
callback.book()?.let { } else {
tv_chapter_name.paint.isFakeBoldText = BookHelp.hasContent(it, item) val hasContent = payloads[0] as Boolean
tv_chapter_name.paint.isFakeBoldText = hasContent
} }
} }
} }

Loading…
Cancel
Save