|
|
|
@ -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 |
|
|
|
|
} |
|
|
|
|