Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Mar 6, 2019
1 parent 1a8bf5b commit 7273dae
Showing 1 changed file with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -498,18 +498,9 @@ private final class TTSListener implements TextToSpeech.OnInitListener {
@Override
public void onInit(int i) {
if (i == TextToSpeech.SUCCESS) {
int result = textToSpeech.setLanguage(Locale.CHINA);
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
mainHandler.post(() -> Toast.makeText(ReadAloudService.this, getString(R.string.tts_fix), Toast.LENGTH_SHORT).show());
//先停止朗读服务方便用户设置好后的重试
ReadAloudService.stop(ReadAloudService.this);
//跳转到文字转语音设置界面
toTTSSetting();
} else {
textToSpeech.setOnUtteranceProgressListener(new ttsUtteranceListener());
ttsInitSuccess = true;
playTTS();
}
textToSpeech.setOnUtteranceProgressListener(new ttsUtteranceListener());
ttsInitSuccess = true;
playTTS();
} else {
mainHandler.post(() -> Toast.makeText(ReadAloudService.this, getString(R.string.tts_init_failed), Toast.LENGTH_SHORT).show());
ReadAloudService.this.stopSelf();
Expand Down

0 comments on commit 7273dae

Please sign in to comment.