From 24d0e498c1fd5278f28912efa5027c73fdad5e93 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Tue, 26 Nov 2019 00:07:24 +0200 Subject: [PATCH] Misc.showSoftKeyboard: handle fragemtn.getActivity() returning null --- app/src/main/java/net/ktnx/mobileledger/utils/Misc.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/Misc.java b/app/src/main/java/net/ktnx/mobileledger/utils/Misc.java index bbfa828b..b28900f9 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/Misc.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/Misc.java @@ -22,6 +22,7 @@ import android.content.res.Configuration; import android.view.WindowManager; import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; public class Misc { public static boolean isZero(float f) { @@ -37,6 +38,8 @@ public class Misc { .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } public static void showSoftKeyboard(Fragment fragment) { - showSoftKeyboard(fragment.getActivity()); + final FragmentActivity activity = fragment.getActivity(); + if (activity != null) + showSoftKeyboard(activity); } } -- 2.39.5