feat: 优化代码

pull/155/head^2
kunfei 5 years ago
parent b1f019ffa7
commit 8cd18581a8
  1. 17
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt

@ -42,20 +42,21 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
clearTTS() clearTTS()
} }
@Synchronized
override fun onInit(status: Int) { override fun onInit(status: Int) {
launch { if (status == TextToSpeech.SUCCESS) {
if (status == TextToSpeech.SUCCESS) { textToSpeech?.language = Locale.CHINA
textToSpeech?.language = Locale.CHINA textToSpeech?.setOnUtteranceProgressListener(TTSUtteranceListener())
textToSpeech?.setOnUtteranceProgressListener(TTSUtteranceListener()) ttsIsSuccess = true
ttsIsSuccess = true play()
play() } else {
} else { launch {
toast(R.string.tts_init_failed) toast(R.string.tts_init_failed)
} }
} }
} }
@Suppress("DEPRECATION") @Synchronized
override fun play() { override fun play() {
if (contentList.isEmpty() || !ttsIsSuccess) { if (contentList.isEmpty() || !ttsIsSuccess) {
return return

Loading…
Cancel
Save