Take TextToSpeechSettings out of endless loop
Launching an Activity using startActivityForResult() every time you are in onResume() is a recipe for endless looping. I.e. every time the launched Activity finishes it will be relaunched because the launching Activity reenters onResume(). This change keeps the GetSampleText activity from being launched from onResume if we already have the sample text and the Locale hasn't changed since the last onResume. Fixes bug 15951054. Change-Id: I65d9070df93396d8d3a45a6673ae56826f418122
This commit is contained in:
@@ -47,6 +47,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
||||
@@ -104,7 +105,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
||||
private TextToSpeech mTts = null;
|
||||
private TtsEngines mEnginesHelper = null;
|
||||
|
||||
private String mSampleText = "";
|
||||
private String mSampleText = null;
|
||||
|
||||
/**
|
||||
* Default locale used by selected TTS engine, null if not connected to any engine.
|
||||
@@ -270,10 +271,14 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
||||
|
||||
// ISO-3166 alpha 3 country codes are out of spec. If we won't normalize,
|
||||
// we may end up with English (USA)and German (DEU).
|
||||
final Locale oldDefaultLocale = mCurrentDefaultLocale;
|
||||
mCurrentDefaultLocale = mEnginesHelper.parseLocaleString(defaultLocale.toString());
|
||||
if (!Objects.equals(oldDefaultLocale, mCurrentDefaultLocale)) {
|
||||
mSampleText = null;
|
||||
}
|
||||
|
||||
int defaultAvailable = mTts.setLanguage(defaultLocale);
|
||||
if (evaluateDefaultLocale()) {
|
||||
if (evaluateDefaultLocale() && mSampleText == null) {
|
||||
getSampleText();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user