From 754c0f2b93c65be10adb9fb55d316577e4fc5e22 Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 5 Mar 2013 04:18:54 +0100 Subject: [PATCH] Don't load resources when activity is not attached --- .../fsck/k9/fragment/MessageViewFragment.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/com/fsck/k9/fragment/MessageViewFragment.java b/src/com/fsck/k9/fragment/MessageViewFragment.java index fefa26f48..e3341639e 100644 --- a/src/com/fsck/k9/fragment/MessageViewFragment.java +++ b/src/com/fsck/k9/fragment/MessageViewFragment.java @@ -132,16 +132,32 @@ public class MessageViewFragment extends SherlockFragment implements OnClickList } public void networkError() { - showToast(getString(R.string.status_network_error), Toast.LENGTH_LONG); + // FIXME: This is a hack. Fix the Handler madness! + Context context = getActivity(); + if (context == null) { + return; + } + + showToast(context.getString(R.string.status_network_error), Toast.LENGTH_LONG); } public void invalidIdError() { - showToast(getString(R.string.status_invalid_id_error), Toast.LENGTH_LONG); + Context context = getActivity(); + if (context == null) { + return; + } + + showToast(context.getString(R.string.status_invalid_id_error), Toast.LENGTH_LONG); } public void fetchingAttachment() { - showToast(getString(R.string.message_view_fetching_attachment_toast), Toast.LENGTH_SHORT); + Context context = getActivity(); + if (context == null) { + return; + } + + showToast(context.getString(R.string.message_view_fetching_attachment_toast), Toast.LENGTH_SHORT); } }