From 4d362165cec14fbd667d0541fc08c2dca8f049a4 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 6 Aug 2018 08:39:28 +0000 Subject: [PATCH] Prevent crash when no focus --- app/src/main/java/eu/faircode/email/FragmentEx.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentEx.java b/app/src/main/java/eu/faircode/email/FragmentEx.java index 9d0ca4f7..da168abd 100644 --- a/app/src/main/java/eu/faircode/email/FragmentEx.java +++ b/app/src/main/java/eu/faircode/email/FragmentEx.java @@ -3,6 +3,7 @@ package eu.faircode.email; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.view.View; import android.view.inputmethod.InputMethodManager; public class FragmentEx extends Fragment { @@ -28,7 +29,9 @@ public class FragmentEx extends Fragment { super.onDetach(); InputMethodManager im = getContext().getSystemService(InputMethodManager.class); - im.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); + View focussed = getActivity().getCurrentFocus(); + if (focussed != null) + im.hideSoftInputFromWindow(focussed.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } private void updateSubtitle() {