feat: 优化

pull/209/head
kunfei 5 years ago
parent 1e30b0053d
commit 563636cea2
  1. 9
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt

@ -35,10 +35,15 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
textToSpeech = TextToSpeech(this, this) initTts()
upSpeechRate() upSpeechRate()
} }
private fun initTts() {
ttsInitFinish = false
textToSpeech = TextToSpeech(this, this)
}
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
clearTTS() clearTTS()
@ -98,7 +103,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
if (this.getPrefBoolean("ttsFollowSys", true)) { if (this.getPrefBoolean("ttsFollowSys", true)) {
if (reset) { if (reset) {
clearTTS() clearTTS()
textToSpeech = TextToSpeech(this, this) initTts()
} }
} else { } else {
textToSpeech?.setSpeechRate((AppConfig.ttsSpeechRate + 5) / 10f) textToSpeech?.setSpeechRate((AppConfig.ttsSpeechRate + 5) / 10f)

Loading…
Cancel
Save