1
1
package com .wix .reactnativeuilib .keyboardinput ;
2
2
3
+ import android .app .Activity ;
3
4
import android .content .Context ;
4
5
import android .view .View ;
5
6
import android .view .Window ;
@@ -89,14 +90,17 @@ public void forceReset(final Promise promise) {
89
90
runOnUIThread (new Runnable () {
90
91
@ Override
91
92
public void run () {
92
- final View focusedView = getCurrentActivity ().getCurrentFocus ();
93
- if (focusedView instanceof EditText ) {
94
- showSoftKeyboard ();
95
- } else {
96
- hideCustomKeyboardContent ();
97
- clearKeyboardOverlayMode ();
93
+ Activity currentActivity = getCurrentActivity ();
94
+ if (currentActivity != null ) {
95
+ final View focusedView = currentActivity .getCurrentFocus ();
96
+ if (focusedView instanceof EditText ) {
97
+ showSoftKeyboard ();
98
+ } else {
99
+ hideCustomKeyboardContent ();
100
+ clearKeyboardOverlayMode ();
101
+ }
102
+ promise .resolve (null );
98
103
}
99
- promise .resolve (null );
100
104
}
101
105
});
102
106
}
@@ -105,9 +109,12 @@ public void clearFocusedView() {
105
109
runOnUIThread (new Runnable () {
106
110
@ Override
107
111
public void run () {
108
- final View focusedView = getCurrentActivity ().getCurrentFocus ();
109
- if (focusedView != null ) {
110
- focusedView .clearFocus ();
112
+ Activity currentActivity = getCurrentActivity ();
113
+ if (currentActivity != null ) {
114
+ final View focusedView = currentActivity .getCurrentFocus ();
115
+ if (focusedView != null ) {
116
+ focusedView .clearFocus ();
117
+ }
111
118
}
112
119
}
113
120
});
0 commit comments