Skip to content

Commit

Permalink
If we got no context, don't allow a NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Su committed Nov 20, 2010
1 parent 69247a0 commit 7c17c66
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/com/todoroo/astrid/data/TaskApiDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@ public static void afterSave(Task task, ContentValues values) {

if(values.containsKey(Task.COMPLETION_DATE.name) && task.isCompleted()) {
Context context = ContextManager.getContext();
Intent broadcastIntent;
broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_COMPLETED);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, task.getId());
context.sendOrderedBroadcast(broadcastIntent, null);
if(context != null) {
Intent broadcastIntent;
broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_COMPLETED);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, task.getId());
context.sendOrderedBroadcast(broadcastIntent, null);
}
}

afterTaskListChanged();
Expand All @@ -172,8 +174,10 @@ public static void afterSave(Task task, ContentValues values) {
*/
public static void afterTaskListChanged() {
Context context = ContextManager.getContext();
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_LIST_UPDATED);
context.sendOrderedBroadcast(broadcastIntent, null);
if(context != null) {
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_TASK_LIST_UPDATED);
context.sendOrderedBroadcast(broadcastIntent, null);
}
}

}

0 comments on commit 7c17c66

Please sign in to comment.