feat: 修复bug

pull/238/head
gedoor 5 years ago
parent 68aa9ab82c
commit 2845e799cc
  1. 1
      app/src/main/java/io/legado/app/service/AudioPlayService.kt
  2. 27
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt
  3. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksAdapterList.kt

@ -520,7 +520,6 @@ class AudioPlayService : BaseService(),
) )
builder.setStyle( builder.setStyle(
androidx.media.app.NotificationCompat.MediaStyle() androidx.media.app.NotificationCompat.MediaStyle()
.setMediaSession(mediaSessionCompat?.sessionToken)
.setShowActionsInCompactView(0, 1, 2) .setShowActionsInCompactView(0, 1, 2)
) )
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)

@ -42,9 +42,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
private fun initTts() { private fun initTts() {
ttsInitFinish = false ttsInitFinish = false
textToSpeech = TextToSpeech(this, this).apply { textToSpeech = TextToSpeech(this, this)
setOnUtteranceProgressListener(ttsUtteranceListener)
}
} }
override fun onDestroy() { override fun onDestroy() {
@ -55,6 +53,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
override fun onInit(status: Int) { override fun onInit(status: Int) {
if (status == TextToSpeech.SUCCESS) { if (status == TextToSpeech.SUCCESS) {
textToSpeech?.let { textToSpeech?.let {
it.setOnUtteranceProgressListener(ttsUtteranceListener)
it.language = Locale.CHINA it.language = Locale.CHINA
ttsInitFinish = true ttsInitFinish = true
play() play()
@ -69,16 +68,20 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
@Synchronized @Synchronized
override fun play() { override fun play() {
if (contentList.isNotEmpty() && ttsInitFinish && requestFocus()) { if (contentList.isNotEmpty() && ttsInitFinish && requestFocus()) {
MediaHelp.playSilentSound(this)
super.play() super.play()
textToSpeech?.stop() execute {
for (i in nowSpeak until contentList.size) { MediaHelp.playSilentSound(this@TTSReadAloudService)
textToSpeech?.speak( textToSpeech?.let {
contentList[i], it.stop()
TextToSpeech.QUEUE_ADD, for (i in nowSpeak until contentList.size) {
null, it.speak(
AppConst.APP_TAG + i contentList[i],
) TextToSpeech.QUEUE_ADD,
null,
AppConst.APP_TAG + i
)
}
}
} }
} }
} }

@ -48,8 +48,8 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) :
rl_loading.show() rl_loading.show()
} else { } else {
rl_loading.hide() rl_loading.hide()
bv_unread.setBadgeCount(item.getUnreadChapterNum())
bv_unread.setHighlight(item.lastCheckCount > 0) bv_unread.setHighlight(item.lastCheckCount > 0)
bv_unread.setBadgeCount(item.getUnreadChapterNum())
} }
} }

Loading…
Cancel
Save