Skip to content

KeyboardInput - fix NPE in CustomKeyboardLayout #1709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wix.reactnativeuilib.keyboardinput;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.Window;
Expand Down Expand Up @@ -89,14 +90,17 @@ public void forceReset(final Promise promise) {
runOnUIThread(new Runnable() {
@Override
public void run() {
final View focusedView = getCurrentActivity().getCurrentFocus();
if (focusedView instanceof EditText) {
showSoftKeyboard();
} else {
hideCustomKeyboardContent();
clearKeyboardOverlayMode();
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
final View focusedView = currentActivity.getCurrentFocus();
if (focusedView instanceof EditText) {
showSoftKeyboard();
} else {
hideCustomKeyboardContent();
clearKeyboardOverlayMode();
}
promise.resolve(null);
}
promise.resolve(null);
}
});
}
Expand All @@ -105,9 +109,12 @@ public void clearFocusedView() {
runOnUIThread(new Runnable() {
@Override
public void run() {
final View focusedView = getCurrentActivity().getCurrentFocus();
if (focusedView != null) {
focusedView.clearFocus();
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
final View focusedView = currentActivity.getCurrentFocus();
if (focusedView != null) {
focusedView.clearFocus();
}
}
}
});
Expand Down