From f7cd351081e0b04a8e6ae89a5d953993a909c35a Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 9 Nov 2019 12:22:36 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/constant/Bus.kt | 3 +-- .../main/java/io/legado/app/receiver/MediaButtonReceiver.kt | 4 ++-- app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt | 2 +- .../main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) 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 c02c1bb7d..38f782615 100644 --- a/app/src/main/java/io/legado/app/constant/Bus.kt +++ b/app/src/main/java/io/legado/app/constant/Bus.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" diff --git a/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt b/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt index 330956351..b56ab9229 100644 --- a/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt +++ b/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt @@ -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) { diff --git a/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt b/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt index fd9a2549c..14c2428a8 100644 --- a/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt +++ b/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt @@ -145,7 +145,7 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a } override fun observeLiveBus() { - observeEvent(Bus.AUDIO_PLAY_BUTTON) { + observeEvent(Bus.MEDIA_BUTTON) { playButton() } observeEventSticky(Bus.AUDIO_STATE) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index f945a3197..d61e03e86 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -559,7 +559,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo viewModel.openChapter(it.index) page_view.upContent() } - observeEvent(Bus.READ_ALOUD_BUTTON) { + observeEvent(Bus.MEDIA_BUTTON) { if (it) { onClickReadAloud() } else {