diff --git a/app/src/main/java/io/legado/app/constant/Bus.kt b/app/src/main/java/io/legado/app/constant/Bus.kt index 03b4d7078..2d7608626 100644 --- a/app/src/main/java/io/legado/app/constant/Bus.kt +++ b/app/src/main/java/io/legado/app/constant/Bus.kt @@ -10,4 +10,5 @@ object Bus { const val TIME_CHANGED = "timeChanged" const val READ_ALOUD = "readAloud" const val UP_CONFIG = "upConfig" + const val OPEN_CHAPTER = "openChapter" } \ No newline at end of file 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 581bf3c01..44f690f52 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 @@ -51,13 +51,13 @@ class ChapterListAdapter(val callback: Callback) : } } itemView.onClick { - callback?.openChapter() + callback?.openChapter(bookChapter) } } } interface Callback { - fun openChapter() + fun openChapter(bookChapter: BookChapter) fun durChapterIndex(): Int } } \ No newline at end of file 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 97eee3cd8..390de1a0c 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 @@ -12,9 +12,11 @@ import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseFragment +import io.legado.app.constant.Bus import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.utils.getViewModelOfActivity +import io.legado.app.utils.postEvent import kotlinx.android.synthetic.main.fragment_chapter_list.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -81,7 +83,8 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragme return durChapterIndex } - override fun openChapter() { - + override fun openChapter(bookChapter: BookChapter) { + postEvent(Bus.OPEN_CHAPTER, bookChapter) + activity?.finish() } } \ No newline at end of file