pull/1072/head
parent
c8be3a3e74
commit
e1b38ac694
@ -1,52 +0,0 @@ |
||||
package io.legado.app.ui.book.info |
||||
|
||||
import android.content.Context |
||||
import android.view.ViewGroup |
||||
import io.legado.app.R |
||||
import io.legado.app.base.adapter.ItemViewHolder |
||||
import io.legado.app.base.adapter.RecyclerAdapter |
||||
import io.legado.app.data.entities.BookChapter |
||||
import io.legado.app.databinding.ItemChapterListBinding |
||||
import io.legado.app.lib.theme.accentColor |
||||
import io.legado.app.utils.getCompatColor |
||||
|
||||
|
||||
class ChapterListAdapter(context: Context, var callBack: CallBack) : |
||||
RecyclerAdapter<BookChapter, ItemChapterListBinding>(context) { |
||||
|
||||
override fun getViewBinding(parent: ViewGroup): ItemChapterListBinding { |
||||
return ItemChapterListBinding.inflate(inflater, parent, false) |
||||
} |
||||
|
||||
override fun convert( |
||||
holder: ItemViewHolder, |
||||
binding: ItemChapterListBinding, |
||||
item: BookChapter, |
||||
payloads: MutableList<Any> |
||||
) { |
||||
with(binding) { |
||||
tvChapterName.text = item.title |
||||
if (item.index == callBack.durChapterIndex()) { |
||||
tvChapterName.setTextColor(context.accentColor) |
||||
} else { |
||||
tvChapterName.setTextColor(context.getCompatColor(R.color.secondaryText)) |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
override fun registerListener(holder: ItemViewHolder, binding: ItemChapterListBinding) { |
||||
holder.itemView.apply { |
||||
this.setOnClickListener { |
||||
getItem(holder.layoutPosition)?.let { |
||||
callBack.openChapter(it) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
interface CallBack { |
||||
fun openChapter(chapter: BookChapter) |
||||
fun durChapterIndex(): Int |
||||
} |
||||
} |
Loading…
Reference in new issue