pull/48/head
kunfei 5 years ago
parent 8601e24be8
commit f7cd351081
  1. 3
      app/src/main/java/io/legado/app/constant/Bus.kt
  2. 4
      app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt
  3. 2
      app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt

@ -1,6 +1,7 @@
package io.legado.app.constant
object Bus {
const val MEDIA_BUTTON = "mediaButton"
const val RECREATE = "RECREATE"
const val UP_BOOK = "sourceDebugLog"
const val ALOUD_STATE = "aloud_state"
@ -9,8 +10,6 @@ object Bus {
const val TTS_DS = "ttsDs"
const val BATTERY_CHANGED = "batteryChanged"
const val TIME_CHANGED = "timeChanged"
const val READ_ALOUD_BUTTON = "readAloudButton"
const val AUDIO_PLAY_BUTTON = "audioPlayButton"
const val UP_CONFIG = "upConfig"
const val OPEN_CHAPTER = "openChapter"
const val REPLACE = "replace"

@ -42,9 +42,9 @@ class MediaButtonReceiver : BroadcastReceiver() {
private fun readAloud(context: Context) {
when {
ActivityHelp.isExist(AudioPlayActivity::class.java) ->
postEvent(Bus.AUDIO_PLAY_BUTTON, true)
postEvent(Bus.MEDIA_BUTTON, true)
ActivityHelp.isExist(ReadBookActivity::class.java) ->
postEvent(Bus.READ_ALOUD_BUTTON, true)
postEvent(Bus.MEDIA_BUTTON, true)
else -> {
GlobalScope.launch(Main) {
val lastBook: Book? = withContext(IO) {

@ -145,7 +145,7 @@ class AudioPlayActivity : VMBaseActivity<AudioPlayViewModel>(R.layout.activity_a
}
override fun observeLiveBus() {
observeEvent<Boolean>(Bus.AUDIO_PLAY_BUTTON) {
observeEvent<Boolean>(Bus.MEDIA_BUTTON) {
playButton()
}
observeEventSticky<Int>(Bus.AUDIO_STATE) {

@ -559,7 +559,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
viewModel.openChapter(it.index)
page_view.upContent()
}
observeEvent<Boolean>(Bus.READ_ALOUD_BUTTON) {
observeEvent<Boolean>(Bus.MEDIA_BUTTON) {
if (it) {
onClickReadAloud()
} else {

Loading…
Cancel
Save