优化朗读逻辑

pull/408/head
口口吕 6 years ago
parent dc96606ec6
commit c47bb91815
  1. 2
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  2. 9
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 5
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt

@ -74,6 +74,7 @@ abstract class BaseReadAloudService : BaseService(),
postEvent(EventBus.ALOUD_STATE, Status.STOP)
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_STOPPED)
mediaSessionCompat.release()
stopForeground(true)
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
@ -148,6 +149,7 @@ abstract class BaseReadAloudService : BaseService(),
if (timeMinute > 1) {
doDs()
}
postEvent(EventBus.ALOUD_STATE, Status.PLAY)
}
abstract fun upSpeechRate(reset: Boolean = false)

@ -850,6 +850,13 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
override fun onDestroy() {
super.onDestroy()
ReadBook.curTextChapter?.let { textChapter ->
val page = textChapter.page(ReadBook.durPageIndex)
if (page != null) {
page.removePageAloudSpan()
page_view.upContent(resetPageOffset = false)
}
}
mHandler.removeCallbacks(keepScreenRunnable)
textActionMenu?.dismiss()
page_view.onDestroy()
@ -887,7 +894,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
}
}
observeEvent<Int>(EventBus.ALOUD_STATE) {
if (it == Status.STOP || it == Status.PAUSE) {
if (it == Status.STOP) {
ReadBook.curTextChapter?.let { textChapter ->
val page = textChapter.page(ReadBook.durPageIndex)
if (page != null) {

@ -126,7 +126,10 @@ class ReadAloudDialog : BaseDialogFragment() {
}
tv_pre.onClick { ReadBook.moveToPrevChapter(upContent = true, toLast = false) }
tv_next.onClick { ReadBook.moveToNextChapter(true) }
iv_stop.onClick { ReadAloud.stop(requireContext()); dismiss() }
iv_stop.onClick {
ReadAloud.stop(requireContext())
dismiss()
}
iv_play_pause.onClick { callBack?.onClickReadAloud() }
iv_play_prev.onClick { ReadAloud.prevParagraph(requireContext()) }
iv_play_next.onClick { ReadAloud.nextParagraph(requireContext()) }

Loading…
Cancel
Save