From 351c6af58ea218e6458bab04a00f3c5e72aef87b Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 22 Oct 2018 05:02:22 +0000 Subject: [PATCH] Prevent crash --- .../main/java/eu/faircode/email/FragmentCompose.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index dad965f7..085f2785 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -20,6 +20,7 @@ package eu.faircode.email; */ import android.Manifest; +import android.app.Activity; import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; @@ -193,7 +194,9 @@ public class FragmentCompose extends FragmentEx { public void onFocusChange(View view, boolean hasFocus) { free = hasFocus; - getActivity().invalidateOptionsMenu(); + Activity activity = getActivity(); + if (activity != null) + activity.invalidateOptionsMenu(); grpHeader.setVisibility(hasFocus ? View.GONE : View.VISIBLE); if (hasFocus) { @@ -213,7 +216,10 @@ public class FragmentCompose extends FragmentEx { if (grpHeader.getVisibility() == View.GONE) { free = false; - getActivity().invalidateOptionsMenu(); + Activity activity = getActivity(); + if (activity != null) + activity.invalidateOptionsMenu(); + grpHeader.setVisibility(View.VISIBLE); if (addresses) grpAddresses.setVisibility(View.VISIBLE);