Fix window leak problems in settings.

There were window leak in the settings application.
These leak happens when an AlertDialog displays, rotate the phone,
then it would cause window leak.

Change-Id: I914897bf657933efea72eeea66076dc288098420
This commit is contained in:
Jiehua.Dai
2010-05-12 08:37:52 +02:00
committed by Johan Redestig
parent 05c2b96f42
commit 20108e2ed6
6 changed files with 208 additions and 79 deletions

View File

@@ -40,6 +40,8 @@ public class SettingsSafetyLegalActivity extends AlertActivity
private WebView mWebView;
private AlertDialog mErrorDialog = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -85,14 +87,31 @@ public class SettingsSafetyLegalActivity extends AlertActivity
}
private void showErrorAndFinish(String url) {
new AlertDialog.Builder(this)
.setMessage(getResources()
.getString(R.string.settings_safetylegal_activity_unreachable, url))
.setTitle(R.string.settings_safetylegal_activity_title)
.setPositiveButton(android.R.string.ok, this)
.setOnCancelListener(this)
.setCancelable(true)
.show();
if (mErrorDialog == null) {
mErrorDialog = new AlertDialog.Builder(this)
.setTitle(R.string.settings_safetylegal_activity_title)
.setPositiveButton(android.R.string.ok, this)
.setOnCancelListener(this)
.setCancelable(true)
.create();
} else {
if (mErrorDialog.isShowing()) {
mErrorDialog.dismiss();
}
}
mErrorDialog.setMessage(getResources()
.getString(R.string.settings_safetylegal_activity_unreachable, url));
mErrorDialog.show();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mErrorDialog != null) {
mErrorDialog.dismiss();
mErrorDialog = null;
}
}
@Override