diff --git a/android/src/com/reecedunn/espeak/TtsService.java b/android/src/com/reecedunn/espeak/TtsService.java index 2235d456653ed010a38d56c9753d99c4869943a7..d8f7dbf2ae3f242562434d7b3ee30e2a9ed080c7 100644 --- a/android/src/com/reecedunn/espeak/TtsService.java +++ b/android/src/com/reecedunn/espeak/TtsService.java @@ -94,7 +94,9 @@ public class TtsService extends TextToSpeechService { if (mOnLanguagesDownloaded != null) { unregisterReceiver(mOnLanguagesDownloaded); } - mAsyncExtract.cancel(true); + if (mAsyncExtract != null) { + mAsyncExtract.cancel(true); + } } /** @@ -120,12 +122,12 @@ public class TtsService extends TextToSpeechService { protected String[] onGetLanguage() { // This is used to specify the language requested from GetSampleText. if (mMatchingVoice == null) { - return new String[] { "eng", "GBR", "" }; + return new String[]{"eng", "GBR", ""}; } - return new String[] { - mMatchingVoice.locale.getISO3Language(), - mMatchingVoice.locale.getISO3Country(), - mMatchingVoice.locale.getVariant() + return new String[]{ + mMatchingVoice.locale.getISO3Language(), + mMatchingVoice.locale.getISO3Country(), + mMatchingVoice.locale.getVariant() }; } @@ -146,17 +148,17 @@ public class TtsService extends TextToSpeechService { final File dataPath = CheckVoiceData.getDataPath(this).getParentFile(); mAsyncExtract = new AsyncExtract(this, R.raw.espeakdata, dataPath) { - @Override - protected void onPostExecute(Integer result) { - switch (result) { - case RESULT_OK: - final Intent intent = new Intent(DownloadVoiceData.BROADCAST_LANGUAGES_UPDATED); - sendBroadcast(intent); - break; - case RESULT_CANCELED: - // Do nothing? - break; - } + @Override + protected void onPostExecute(Integer result) { + switch (result) { + case RESULT_OK: + final Intent intent = new Intent(DownloadVoiceData.BROADCAST_LANGUAGES_UPDATED); + sendBroadcast(intent); + break; + case RESULT_CANCELED: + // Do nothing? + break; + } } }; @@ -320,8 +322,7 @@ public class TtsService extends TextToSpeechService { } } - if (text.startsWith("" preprocessing tags, // so need to remove these before passing to synthesize. text = text.substring(text.indexOf("?>") + 2).trim(); @@ -371,8 +372,8 @@ public class TtsService extends TextToSpeechService { /** - * Begin voice data download here instead of an activity. - */ + * Begin voice data download here instead of an activity. + */ private static final int PROGRESS_STARTING = 0; private static final int PROGRESS_EXTRACTING = 1;