am eb6f9c08: Merge change I0ad3fc43 into eclair
Merge commit 'eb6f9c0824ed739ad4fbfeef19ac1b54553a0914' into eclair-mr2
* commit 'eb6f9c0824ed739ad4fbfeef19ac1b54553a0914':
Avoid IAE by only dismissing dialog when still attached.
diff --git a/src/com/android/contacts/ui/EditContactActivity.java b/src/com/android/contacts/ui/EditContactActivity.java
index 5f4328a..269e63b 100644
--- a/src/com/android/contacts/ui/EditContactActivity.java
+++ b/src/com/android/contacts/ui/EditContactActivity.java
@@ -587,7 +587,7 @@
private static final int RESULT_SUCCESS = 1;
private static final int RESULT_FAILURE = 2;
- private WeakReference<ProgressDialog> progress;
+ private WeakReference<ProgressDialog> mProgress;
private int mSaveMode;
private Uri mContactLookupUri = null;
@@ -600,7 +600,7 @@
/** {@inheritDoc} */
@Override
protected void onPreExecute(EditContactActivity target) {
- this.progress = new WeakReference<ProgressDialog>(ProgressDialog.show(target, null,
+ mProgress = new WeakReference<ProgressDialog>(ProgressDialog.show(target, null,
target.getText(R.string.savingContact)));
// Before starting this task, start an empty service to protect our
@@ -687,6 +687,7 @@
@Override
protected void onPostExecute(EditContactActivity target, Integer result) {
final Context context = target;
+ final ProgressDialog progress = mProgress.get();
if (result == RESULT_SUCCESS && mSaveMode != SAVE_MODE_JOIN) {
Toast.makeText(context, R.string.contactSavedToast, Toast.LENGTH_SHORT).show();
@@ -694,7 +695,10 @@
Toast.makeText(context, R.string.contactSavedErrorToast, Toast.LENGTH_LONG).show();
}
- progress.get().dismiss();
+ // Only dismiss when valid reference and still showing
+ if (progress != null && progress.isShowing()) {
+ progress.dismiss();
+ }
// Stop the service that was protecting us
context.stopService(new Intent(context, EmptyService.class));