From 06330e4f450515731ef171ab9fb07f256b5537ac Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 14 Jul 2011 14:38:44 -0700 Subject: [PATCH] Use dismiss Dialog instead of dialog.dismiss() where possible --- .../todoroo/astrid/backup/TasksXmlExporter.java | 5 +++-- .../todoroo/astrid/backup/TasksXmlImporter.java | 5 +++-- .../astrid/producteev/ProducteevControlSet.java | 14 +++++--------- .../astrid/producteev/ProducteevLoginActivity.java | 4 ++-- .../todoroo/astrid/activity/EditPreferences.java | 2 -- .../astrid/activity/FilterListActivity.java | 4 ++-- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlExporter.java b/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlExporter.java index 646cc78f9..e75a54a54 100644 --- a/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlExporter.java +++ b/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlExporter.java @@ -23,6 +23,7 @@ import com.todoroo.andlib.service.ExceptionService; import com.todoroo.andlib.sql.Order; import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.utility.DateUtilities; +import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria; @@ -298,8 +299,8 @@ public class TasksXmlExporter { context.getResources().getQuantityString(R.plurals.Ntasks, exportCount, exportCount), outputFile); Toast.makeText(context, text, Toast.LENGTH_LONG).show(); - if(progressDialog.isShowing()) - progressDialog.dismiss(); + if(progressDialog.isShowing() && context instanceof Activity) + DialogUtilities.dismissDialog((Activity) context, progressDialog); } } }); diff --git a/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlImporter.java b/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlImporter.java index 32d6e781d..43c0ef1a5 100644 --- a/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlImporter.java +++ b/astrid/plugin-src/com/todoroo/astrid/backup/TasksXmlImporter.java @@ -32,6 +32,7 @@ import com.todoroo.andlib.service.ExceptionService; import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.utility.DateUtilities; +import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.data.Metadata; @@ -152,8 +153,8 @@ public class TasksXmlImporter { handler.post(new Runnable() { @Override public void run() { - if(progressDialog != null && progressDialog.isShowing()) - progressDialog.dismiss(); + if(progressDialog.isShowing() && context instanceof Activity) + DialogUtilities.dismissDialog((Activity) context, progressDialog); showSummary(); } }); diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java index 98f0cc947..6c4ac4ca3 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevControlSet.java @@ -22,6 +22,7 @@ import android.widget.TextView; import com.timsu.astrid.R; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.DependencyInjectionService; +import com.todoroo.andlib.service.ExceptionService.ErrorReporter; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.Preferences; @@ -56,8 +57,8 @@ public class ProducteevControlSet implements TaskEditControlSet { private ArrayList users = null; private ArrayList dashboards = null; - @Autowired - MetadataService metadataService; + @Autowired MetadataService metadataService; + @Autowired ErrorReporter errorReporter; private int lastDashboardSelection = 0; @@ -112,13 +113,8 @@ public class ProducteevControlSet implements TaskEditControlSet { DialogUtilities.dismissDialog(context, progressDialog); DialogUtilities.okDialog(context, context.getString(R.string.DLG_error, e.getMessage()), - new OnClickListener() { - @Override - public void onClick(DialogInterface theDialog, int theWhich) { - theDialog.dismiss(); - } - }); - e.printStackTrace(); + null); + errorReporter.handleError("pdv-create-dashboard", e); dashSelector.setSelection(0); } } diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevLoginActivity.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevLoginActivity.java index 997b3ad13..5bd1b4566 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevLoginActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevLoginActivity.java @@ -167,7 +167,7 @@ public class ProducteevLoginActivity extends Activity { } finally { runOnUiThread(new Runnable() { public void run() { - dialog.dismiss(); + DialogUtilities.dismissDialog(ProducteevLoginActivity.this, dialog); if(errorMessage.length() > 0) { errors.setVisibility(View.VISIBLE); errors.setText(errorMessage); @@ -206,7 +206,7 @@ public class ProducteevLoginActivity extends Activity { } finally { runOnUiThread(new Runnable() { public void run() { - dialog.dismiss(); + DialogUtilities.dismissDialog(ProducteevLoginActivity.this, dialog); if(errorMessage.length() > 0) { errors.setVisibility(View.VISIBLE); errors.setText(errorMessage); diff --git a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java index b5f97d5d0..5883f080d 100644 --- a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java +++ b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java @@ -335,7 +335,6 @@ public class EditPreferences extends TodorooPreferenceActivity { public void onClick(DialogInterface dialog, int which) { ((CheckBoxPreference)preference).setChecked(false); - dialog.dismiss(); } }); } else { @@ -346,7 +345,6 @@ public class EditPreferences extends TodorooPreferenceActivity { public void onClick(DialogInterface dialog1, int which1) { ((CheckBoxPreference)preference).setChecked(false); - dialog1.dismiss(); } }); } diff --git a/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java b/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java index f22f9d24f..fcb0e9dfd 100644 --- a/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/FilterListActivity.java @@ -421,7 +421,7 @@ public class FilterListActivity extends ExpandableListActivity { } catch (JSONException e) { exceptionService.displayAndReportError(FilterListActivity.this, "refresh-tags-json", e); } finally { - progressDialog.dismiss(); + DialogUtilities.dismissDialog(FilterListActivity.this, progressDialog); } } }).start(); @@ -469,7 +469,7 @@ public class FilterListActivity extends ExpandableListActivity { } }) .setNegativeButton(android.R.string.cancel, null) - .show(); + .show().setOwnerActivity(this); } @Override