From a319a8967bd6b82c3355ba6d8b23f23b187093ae Mon Sep 17 00:00:00 2001 From: Tim Su Date: Fri, 11 Jun 2010 02:18:27 -0700 Subject: [PATCH] Fix for crashes that people have encountered --- .../com/timsu/astrid/activities/TaskEdit.java | 11 +++++++---- .../com/timsu/astrid/activities/TaskListAdapter.java | 3 ++- .../timsu/astrid/activities/TaskListSubActivity.java | 3 +++ .../timsu/astrid/sync/SynchronizationProvider.java | 8 ++++++-- .../com/timsu/astrid/utilities/Preferences.java | 4 ++-- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/astrid/src-legacy/com/timsu/astrid/activities/TaskEdit.java b/astrid/src-legacy/com/timsu/astrid/activities/TaskEdit.java index a196d6b4d..6f6c57aed 100644 --- a/astrid/src-legacy/com/timsu/astrid/activities/TaskEdit.java +++ b/astrid/src-legacy/com/timsu/astrid/activities/TaskEdit.java @@ -186,10 +186,13 @@ public class TaskEdit extends TaskModificationTabbedActivity { @Override protected TaskModelForEdit getModel(TaskIdentifier identifier) { - if (identifier != null) - return controller.fetchTaskForEdit(this, identifier); - else - return controller.createNewTaskForEdit(); + if (identifier != null) { + TaskModelForEdit task = controller.fetchTaskForEdit(this, identifier); + if(task.getCursor().getCount() > 0) + return task; + } + + return controller.createNewTaskForEdit(); } /* ====================================================================== diff --git a/astrid/src-legacy/com/timsu/astrid/activities/TaskListAdapter.java b/astrid/src-legacy/com/timsu/astrid/activities/TaskListAdapter.java index 10a73a131..2d4e03dce 100644 --- a/astrid/src-legacy/com/timsu/astrid/activities/TaskListAdapter.java +++ b/astrid/src-legacy/com/timsu/astrid/activities/TaskListAdapter.java @@ -287,7 +287,8 @@ public class TaskListAdapter extends ArrayAdapter { // expanded container final View expandedContainer = view.findViewById(R.id.expanded_layout); - expandedContainer.setVisibility(isExpanded ? View.VISIBLE : View.GONE); + if(expandedContainer == null) + expandedContainer.setVisibility(isExpanded ? View.VISIBLE : View.GONE); // name final TextView name = ((TextView)view.findViewById(R.id.task_name)); { diff --git a/astrid/src-legacy/com/timsu/astrid/activities/TaskListSubActivity.java b/astrid/src-legacy/com/timsu/astrid/activities/TaskListSubActivity.java index 82638c257..eea30f73c 100644 --- a/astrid/src-legacy/com/timsu/astrid/activities/TaskListSubActivity.java +++ b/astrid/src-legacy/com/timsu/astrid/activities/TaskListSubActivity.java @@ -1065,6 +1065,9 @@ public class TaskListSubActivity extends SubActivity { /** Toggle the timer */ private void toggleTimer(TaskModelForList task) { + if(task == null) + return; + if (task.getTimerStart() == null) { FlurryAgent.onEvent("start-timer"); task.setTimerStart(new Date()); diff --git a/astrid/src-legacy/com/timsu/astrid/sync/SynchronizationProvider.java b/astrid/src-legacy/com/timsu/astrid/sync/SynchronizationProvider.java index a78ac6f53..e975312c6 100644 --- a/astrid/src-legacy/com/timsu/astrid/sync/SynchronizationProvider.java +++ b/astrid/src-legacy/com/timsu/astrid/sync/SynchronizationProvider.java @@ -147,8 +147,12 @@ public abstract class SynchronizationProvider { } syncHandler.post(new Runnable() { public void run() { - if(progressDialog != null) - progressDialog.dismiss(); + try { + if(progressDialog != null) + progressDialog.dismiss(); + } catch (Exception e) { + // suppress it + } DialogUtilities.okDialog(context, messageToDisplay, null); } }); diff --git a/astrid/src-legacy/com/timsu/astrid/utilities/Preferences.java b/astrid/src-legacy/com/timsu/astrid/utilities/Preferences.java index 6a5e28e4c..d5abe456b 100644 --- a/astrid/src-legacy/com/timsu/astrid/utilities/Preferences.java +++ b/astrid/src-legacy/com/timsu/astrid/utilities/Preferences.java @@ -170,9 +170,9 @@ public class Preferences { // united states, you are special if(Locale.US.equals(Locale.getDefault()) || Locale.CANADA.equals(Locale.getDefault())) - return new SimpleDateFormat("EEE MMM d yy"); + return new SimpleDateFormat("EEE, MMM d yyyy"); else - return new SimpleDateFormat("EEE d MMM yy"); + return new SimpleDateFormat("EEE, d MMM yyyy"); } // --- notification settings