pull/32/head
kunfei 5 years ago
parent 8551379fd8
commit 507b35a8db
  1. 10
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt
  2. 6
      app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt

@ -24,7 +24,9 @@ import kotlinx.android.synthetic.main.view_title_bar.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_book_info), ChangeSourceDialog.CallBack { class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_book_info),
ChapterListAdapter.CallBack,
ChangeSourceDialog.CallBack {
override val viewModel: BookInfoViewModel override val viewModel: BookInfoViewModel
get() = getViewModel(BookInfoViewModel::class.java) get() = getViewModel(BookInfoViewModel::class.java)
@ -134,7 +136,7 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
} }
private fun initRecyclerView() { private fun initRecyclerView() {
adapter = ChapterListAdapter(this) adapter = ChapterListAdapter(this, this)
ATH.applyEdgeEffectColor(rv_chapter_list) ATH.applyEdgeEffectColor(rv_chapter_list)
rv_chapter_list.layoutManager = LinearLayoutManager(this) rv_chapter_list.layoutManager = LinearLayoutManager(this)
rv_chapter_list.addItemDecoration(DividerItemDecoration(this, LinearLayout.VERTICAL)) rv_chapter_list.addItemDecoration(DividerItemDecoration(this, LinearLayout.VERTICAL))
@ -178,4 +180,8 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
override fun changeTo(book: Book) { override fun changeTo(book: Book) {
} }
override fun skipToChapter(index: Int) {
}
} }

@ -8,14 +8,14 @@ import io.legado.app.data.entities.BookChapter
import kotlinx.android.synthetic.main.item_chapter_list.view.* import kotlinx.android.synthetic.main.item_chapter_list.view.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
class ChapterListAdapter(context: Context) : SimpleRecyclerAdapter<BookChapter>(context, R.layout.item_chapter_list) { class ChapterListAdapter(context: Context, var callBack: CallBack) :
var callBack: CallBack? = null SimpleRecyclerAdapter<BookChapter>(context, R.layout.item_chapter_list) {
override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList<Any>) { override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList<Any>) {
holder.itemView.apply { holder.itemView.apply {
tv_chapter_name.text = item.title tv_chapter_name.text = item.title
this.onClick { this.onClick {
callBack?.skipToChapter(item.index) callBack.skipToChapter(item.index)
} }
} }
} }

Loading…
Cancel
Save