Browse Source

Remove keyboard listener once it's called

Guy Carmeli 8 years ago
parent
commit
9ccdd124ed

+ 3
- 1
android/app/src/main/java/com/reactnativenavigation/screens/ScreenStack.java View File

111
         final Screen previous = stack.peek();
111
         final Screen previous = stack.peek();
112
 
112
 
113
         if (keyboardVisibilityDetector.isKeyboardVisible()) {
113
         if (keyboardVisibilityDetector.isKeyboardVisible()) {
114
-            keyboardVisibilityDetector.closeKeyboard(new Runnable() {
114
+            keyboardVisibilityDetector.setKeyboardCloseListener(new Runnable() {
115
                 @Override
115
                 @Override
116
                 public void run() {
116
                 public void run() {
117
+                    keyboardVisibilityDetector.setKeyboardCloseListener(null);
117
                     swapScreens(animated, toRemove, previous, onScreenPop);
118
                     swapScreens(animated, toRemove, previous, onScreenPop);
118
                 }
119
                 }
119
             });
120
             });
121
+            keyboardVisibilityDetector.closeKeyboard();
120
         } else {
122
         } else {
121
             swapScreens(animated, toRemove, previous, onScreenPop);
123
             swapScreens(animated, toRemove, previous, onScreenPop);
122
         }
124
         }

+ 5
- 2
android/app/src/main/java/com/reactnativenavigation/utils/KeyboardVisibilityDetector.java View File

26
         return keyboardVisibilityListener.isKeyboardVisible();
26
         return keyboardVisibilityListener.isKeyboardVisible();
27
     }
27
     }
28
 
28
 
29
-    public void closeKeyboard(Runnable keyboardClosedListener) {
30
-        this.keyboardCloseListener = keyboardClosedListener;
29
+    public void setKeyboardCloseListener(Runnable keyboardCloseListener) {
30
+        this.keyboardCloseListener = keyboardCloseListener;
31
+    }
32
+
33
+    public void closeKeyboard() {
31
         InputMethodManager imm = (InputMethodManager) screen.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
34
         InputMethodManager imm = (InputMethodManager) screen.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
32
         imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
35
         imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
33
     }
36
     }