Skip to content

Commit d9c0dc5

Browse files
authored
Fix a crash (Android) - CustomKeyboardLayout -> clearKeyboardOverlayMode -> NullPointer (#869)
1 parent ba1f4de commit d9c0dc5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/CustomKeyboardLayout.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44
import android.view.View;
5+
import android.view.Window;
56
import android.view.WindowManager;
67
import android.view.inputmethod.InputMethodManager;
78
import android.widget.EditText;
@@ -166,11 +167,17 @@ private int getHeightForCustomContent() {
166167
}
167168

168169
private void setKeyboardOverlayMode() {
169-
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
170+
Window window = getWindow();
171+
if (window != null) {
172+
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
173+
}
170174
}
171175

172176
private void clearKeyboardOverlayMode() {
173-
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
177+
Window window = getWindow();
178+
if (window != null) {
179+
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
180+
}
174181
}
175182

176183
private void sendCustomKeyboardResignedEvent() {

0 commit comments

Comments
 (0)