Don't rely on Activity to set the context for ops
The Fragment can get detached from the activity prior to performing an operation, so for now, use the context reference that the fragment has instead. In the long run, we should avoid referencing the application context, but a restructuring of ActivityHelper may help instead. Bug: 4332451 Change-Id: Ieabff8ec0cc363f7d2eebd3ed47c230df9959886
This commit is contained in:
parent
23b441a5c8
commit
a6e6b9969a
|
@ -415,7 +415,7 @@ public class MessageViewFragment extends MessageViewFragmentBase
|
|||
|
||||
private void onDelete() {
|
||||
mCallback.onBeforeMessageDelete();
|
||||
ActivityHelper.deleteMessage(getActivity(), mCurrentMessageId);
|
||||
ActivityHelper.deleteMessage(mContext, mCurrentMessageId);
|
||||
}
|
||||
|
||||
private void onMarkAsUnread() {
|
||||
|
|
|
@ -100,7 +100,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
|||
private static final String BUNDLE_KEY_CURRENT_TAB = "MessageViewFragmentBase.currentTab";
|
||||
private static final String BUNDLE_KEY_PICTURE_LOADED = "MessageViewFragmentBase.pictureLoaded";
|
||||
private static final int PHOTO_LOADER_ID = 1;
|
||||
private Context mContext;
|
||||
protected Context mContext;
|
||||
|
||||
// Regex that matches start of img tag. '<(?i)img\s+'.
|
||||
private static final Pattern IMG_TAG_START_REGEX = Pattern.compile("<(?i)img\\s+");
|
||||
|
|
Loading…
Reference in New Issue