Fix crash when activity is null in update adapter

pull/14/head
Sam Bosley 13 years ago
parent 6b177109fb
commit 31c21d5117

@ -53,7 +53,6 @@ public class UpdateAdapter extends CursorAdapter {
// --- instance variables // --- instance variables
protected final Fragment fragment; protected final Fragment fragment;
protected final AstridActivity activity;
private final int resource; private final int resource;
private final LayoutInflater inflater; private final LayoutInflater inflater;
private final ImageDiskCache imageCache; private final ImageDiskCache imageCache;
@ -107,7 +106,6 @@ public class UpdateAdapter extends CursorAdapter {
this.resource = resource; this.resource = resource;
this.fragment = fragment; this.fragment = fragment;
this.activity = (AstridActivity) fragment.getActivity();
} }
public static String getLinkColor(Fragment f) { public static String getLinkColor(Fragment f) {
@ -163,7 +161,7 @@ public class UpdateAdapter extends CursorAdapter {
// name // name
final TextView nameView = (TextView)view.findViewById(R.id.title); { 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()); nameView.setMovementMethod(new LinkMovementMethod());
} }
@ -369,6 +367,7 @@ public class UpdateAdapter extends CursorAdapter {
taskSpan.setSpan(new ClickableSpan() { taskSpan.setSpan(new ClickableSpan() {
@Override @Override
public void onClick(View widget) { public void onClick(View widget) {
if (activity != null) // TODO: This shouldn't happen, but sometimes does
activity.onTaskListItemClicked(taskIdToUse); activity.onTaskListItemClicked(taskIdToUse);
} }
}, 0, targetName.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); }, 0, targetName.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);

Loading…
Cancel
Save