From e26532ec7f97df5984f9d172fc9c7195c7aadc04 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 22 Aug 2019 20:28:07 +0800 Subject: [PATCH] up --- .../legado/app/ui/chapterlist/ChapterListAdapter.kt | 12 +++++++++--- .../legado/app/ui/chapterlist/ChapterListFragment.kt | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListAdapter.kt index 44f690f52..aff557711 100644 --- a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListAdapter.kt @@ -7,7 +7,9 @@ import androidx.paging.PagedListAdapter import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import io.legado.app.R +import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter +import io.legado.app.help.BookHelp import io.legado.app.lib.theme.accentColor import io.legado.app.utils.getCompatColor import kotlinx.android.synthetic.main.item_bookmark.view.* @@ -41,9 +43,9 @@ class ChapterListAdapter(val callback: Callback) : class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) { - fun bind(bookChapter: BookChapter, callback: Callback?) = with(itemView) { + fun bind(bookChapter: BookChapter, callback: Callback) = with(itemView) { tv_chapter_name.text = bookChapter.title - callback?.let { + callback.let { if (it.durChapterIndex() == bookChapter.index) { tv_chapter_name.setTextColor(context.accentColor) } else { @@ -51,12 +53,16 @@ class ChapterListAdapter(val callback: Callback) : } } itemView.onClick { - callback?.openChapter(bookChapter) + callback.openChapter(bookChapter) + } + callback.book()?.let { + tv_chapter_name.paint.isFakeBoldText = BookHelp.hasContent(it, bookChapter) } } } interface Callback { + fun book(): Book? fun openChapter(bookChapter: BookChapter) fun durChapterIndex(): Int } diff --git a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt index 390de1a0c..dacc8a851 100644 --- a/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt +++ b/app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt @@ -87,4 +87,8 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragme postEvent(Bus.OPEN_CHAPTER, bookChapter) activity?.finish() } + + override fun book(): Book? { + return viewModel.bookDate.value + } } \ No newline at end of file