Fix a pseudo race condition in TtsEngineSettingsFragment.

The issue is that Fragment.setVoiceDataDetails can
be called before Fragment.getView. We guard against this
issue. No thread visibility issues here because both functions
are called on the UI thread.

bug:5884355
Change-Id: Iad91b91c58b04dcb9f34f6b5ff8752f2e8295423
This commit is contained in:
Narayan Kamath
2012-01-20 17:52:02 +00:00
parent af48709993
commit 2d8101bc8b

View File

@@ -155,12 +155,21 @@ public class TtsEnginePreference extends Preference {
}
});
if (mVoiceCheckData != null) {
mSettingsIcon.setEnabled(mRadioButton.isChecked());
}
return view;
}
public void setVoiceDataDetails(Intent data) {
mVoiceCheckData = data;
mSettingsIcon.setEnabled(mRadioButton.isChecked());
// This might end up running before getView aboive, in which
// case mSettingsIcon && mRadioButton will be null. In this case
// getView will set the right values.
if (mSettingsIcon != null && mRadioButton != null) {
mSettingsIcon.setEnabled(mRadioButton.isChecked());
}
}
private void onRadioButtonClicked(CompoundButton buttonView, boolean isChecked) {