Commit 27d2a56e authored by Matheus Jardim's avatar Matheus Jardim

replicating #277 code changes

parent e1f68b13
...@@ -7,9 +7,10 @@ import android.view.inputmethod.InputMethodManager; ...@@ -7,9 +7,10 @@ import android.view.inputmethod.InputMethodManager;
public class KeyboardHelper { public class KeyboardHelper {
public static void hideSoftKeyboard(Activity activity) { public static void hideSoftKeyboard(Activity activity) {
if (activity.getCurrentFocus() != null) { View currentFocus = activity.getCurrentFocus();
if (currentFocus != null) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); inputMethodManager.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
} }
} }
...@@ -23,4 +24,4 @@ public class KeyboardHelper { ...@@ -23,4 +24,4 @@ public class KeyboardHelper {
InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment