From 507b35a8db9e0acc253f0a85740b00a8a1fce307 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 18 Aug 2019 08:02:36 +0800 Subject: [PATCH] up --- .../java/io/legado/app/ui/bookinfo/BookInfoActivity.kt | 10 ++++++++-- .../io/legado/app/ui/bookinfo/ChapterListAdapter.kt | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt index f66635458..d22b3bbaa 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt @@ -24,7 +24,9 @@ import kotlinx.android.synthetic.main.view_title_bar.* import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.startActivity -class BookInfoActivity : VMBaseActivity(R.layout.activity_book_info), ChangeSourceDialog.CallBack { +class BookInfoActivity : VMBaseActivity(R.layout.activity_book_info), + ChapterListAdapter.CallBack, + ChangeSourceDialog.CallBack { override val viewModel: BookInfoViewModel get() = getViewModel(BookInfoViewModel::class.java) @@ -134,7 +136,7 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo } private fun initRecyclerView() { - adapter = ChapterListAdapter(this) + adapter = ChapterListAdapter(this, this) ATH.applyEdgeEffectColor(rv_chapter_list) rv_chapter_list.layoutManager = LinearLayoutManager(this) rv_chapter_list.addItemDecoration(DividerItemDecoration(this, LinearLayout.VERTICAL)) @@ -178,4 +180,8 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo override fun changeTo(book: Book) { } + + override fun skipToChapter(index: Int) { + + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt index db2797eb2..cd5a759db 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt @@ -8,14 +8,14 @@ import io.legado.app.data.entities.BookChapter import kotlinx.android.synthetic.main.item_chapter_list.view.* import org.jetbrains.anko.sdk27.listeners.onClick -class ChapterListAdapter(context: Context) : SimpleRecyclerAdapter(context, R.layout.item_chapter_list) { - var callBack: CallBack? = null +class ChapterListAdapter(context: Context, var callBack: CallBack) : + SimpleRecyclerAdapter(context, R.layout.item_chapter_list) { override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList) { holder.itemView.apply { tv_chapter_name.text = item.title this.onClick { - callBack?.skipToChapter(item.index) + callBack.skipToChapter(item.index) } } }