pull/32/head
kunfei 5 years ago
parent de103d2f5d
commit b3a9c875ce
  1. 1
      app/src/main/java/io/legado/app/constant/Bus.kt
  2. 4
      app/src/main/java/io/legado/app/ui/chapterlist/ChapterListAdapter.kt
  3. 7
      app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt

@ -10,4 +10,5 @@ object Bus {
const val TIME_CHANGED = "timeChanged" const val TIME_CHANGED = "timeChanged"
const val READ_ALOUD = "readAloud" const val READ_ALOUD = "readAloud"
const val UP_CONFIG = "upConfig" const val UP_CONFIG = "upConfig"
const val OPEN_CHAPTER = "openChapter"
} }

@ -51,13 +51,13 @@ class ChapterListAdapter(val callback: Callback) :
} }
} }
itemView.onClick { itemView.onClick {
callback?.openChapter() callback?.openChapter(bookChapter)
} }
} }
} }
interface Callback { interface Callback {
fun openChapter() fun openChapter(bookChapter: BookChapter)
fun durChapterIndex(): Int fun durChapterIndex(): Int
} }
} }

@ -12,9 +12,11 @@ import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseFragment 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.Book
import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookChapter
import io.legado.app.utils.getViewModelOfActivity import io.legado.app.utils.getViewModelOfActivity
import io.legado.app.utils.postEvent
import kotlinx.android.synthetic.main.fragment_chapter_list.* import kotlinx.android.synthetic.main.fragment_chapter_list.*
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
@ -81,7 +83,8 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme
return durChapterIndex return durChapterIndex
} }
override fun openChapter() { override fun openChapter(bookChapter: BookChapter) {
postEvent(Bus.OPEN_CHAPTER, bookChapter)
activity?.finish()
} }
} }
Loading…
Cancel
Save