From 31c21d51178e2c5af73de97390698bfc7ffc238e Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 4 Jun 2012 17:28:53 -0700 Subject: [PATCH] Fix crash when activity is null in update adapter --- astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java b/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java index 6a80afe14..8bb07981b 100644 --- a/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/UpdateAdapter.java @@ -53,7 +53,6 @@ public class UpdateAdapter extends CursorAdapter { // --- instance variables protected final Fragment fragment; - protected final AstridActivity activity; private final int resource; private final LayoutInflater inflater; private final ImageDiskCache imageCache; @@ -107,7 +106,6 @@ public class UpdateAdapter extends CursorAdapter { this.resource = resource; this.fragment = fragment; - this.activity = (AstridActivity) fragment.getActivity(); } public static String getLinkColor(Fragment f) { @@ -163,7 +161,7 @@ public class UpdateAdapter extends CursorAdapter { // name final TextView nameView = (TextView)view.findViewById(R.id.title); { - nameView.setText(getUpdateComment(activity, update, user, linkColor, fromView)); + nameView.setText(getUpdateComment((AstridActivity)fragment.getActivity(), update, user, linkColor, fromView)); nameView.setMovementMethod(new LinkMovementMethod()); } @@ -369,7 +367,8 @@ public class UpdateAdapter extends CursorAdapter { taskSpan.setSpan(new ClickableSpan() { @Override public void onClick(View widget) { - activity.onTaskListItemClicked(taskIdToUse); + if (activity != null) // TODO: This shouldn't happen, but sometimes does + activity.onTaskListItemClicked(taskIdToUse); } }, 0, targetName.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); return taskSpan;