Fix crash after adding a word to the user dictionary.

Bug: 3407951

Make sure that the parent fragment is a SettingsPreferenceFragment. Otherwise it's not
necessary to manage the mDialogFragment.

Change-Id: I331a3507fe11a7331ff24ecf64fe8c8c3f613636
This commit is contained in:
Amith Yamasani
2011-01-31 12:46:57 -08:00
parent 171412000a
commit 8875edede1

View File

@@ -182,9 +182,12 @@ public class SettingsPreferenceFragment extends PreferenceFragment
+ DialogCreatable.class.getName());
}
}
// This dialog fragment could be created from non-SettingsPreferenceFragment
if (mParentFragment instanceof SettingsPreferenceFragment) {
// restore mDialogFragment in mParentFragment
((SettingsPreferenceFragment) mParentFragment).mDialogFragment = this;
}
}
return ((DialogCreatable) mParentFragment).onCreateDialog(mDialogId);
}
@@ -203,6 +206,7 @@ public class SettingsPreferenceFragment extends PreferenceFragment
mOnDismissListener.onDismiss(dialog);
}
}
public int getDialogId() {
return mDialogId;
}
@@ -211,12 +215,15 @@ public class SettingsPreferenceFragment extends PreferenceFragment
public void onDetach() {
super.onDetach();
// This dialog fragment could be created from non-SettingsPreferenceFragment
if (mParentFragment instanceof SettingsPreferenceFragment) {
// in case the dialog is not explicitly removed by removeDialog()
if (((SettingsPreferenceFragment) mParentFragment).mDialogFragment == this) {
((SettingsPreferenceFragment) mParentFragment).mDialogFragment = null;
}
}
}
}
protected boolean hasNextButton() {
return ((ButtonBarHandler)getActivity()).hasNextButton();