pull/46/head
kunfei 5 years ago
parent c686427c70
commit 6bcba7010b
  1. 1
      app/src/main/java/io/legado/app/constant/Bus.kt
  2. 11
      app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt

@ -15,4 +15,5 @@ object Bus {
const val REPLACE = "replace"
const val AUDIO_NEXT = "audioNext"
const val AUDIO_CUR_POS = "audioCurPos"
const val AUDIO_STATE = "audioState"
}

@ -4,6 +4,7 @@ import android.os.Bundle
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.Bus
import io.legado.app.constant.Status
import io.legado.app.data.entities.BookChapter
import io.legado.app.service.help.AudioPlay
import io.legado.app.utils.getViewModel
@ -18,6 +19,8 @@ class AudioPlayActivity : VMBaseActivity<AudioPlayViewModel>(R.layout.activity_a
override val viewModel: AudioPlayViewModel
get() = getViewModel(AudioPlayViewModel::class.java)
private var status = Status.STOP
override fun onActivityCreated(savedInstanceState: Bundle?) {
setSupportActionBar(toolbar)
viewModel.initData(intent)
@ -47,7 +50,13 @@ class AudioPlayActivity : VMBaseActivity<AudioPlayViewModel>(R.layout.activity_a
override fun observeLiveBus() {
observeEvent<Int>(Bus.AUDIO_NEXT) {
viewModel.durChapterIndex = viewModel.durChapterIndex + 1
viewModel.bookData.value?.let {
viewModel.loadContent(it, viewModel.durChapterIndex)
}
}
observeEvent<Int>(Bus.AUDIO_STATE) {
status = it
}
}
}
Loading…
Cancel
Save