瀏覽代碼

Safegards against NPE in sliding overlay to avoid crashes (#2004)

Varun Gupta 7 年之前
父節點
當前提交
f46cfa8205

+ 5
- 3
android/app/src/main/java/com/reactnativenavigation/views/slidingOverlay/SlidingOverlaysQueue.java 查看文件

@@ -25,7 +25,7 @@ public class SlidingOverlaysQueue implements SlidingOverlay.SlidingListener{
25 25
                 }
26 26
                 else {
27 27
                     SlidingOverlay currentOverlay = queue.peek();
28
-                    if (currentOverlay.isVisible()) {
28
+                    if (currentOverlay != null && currentOverlay.isVisible()) {
29 29
                         if (autoDismissTimer != null) {
30 30
                             autoDismissTimer.cancel();
31 31
                             autoDismissTimer = null;
@@ -60,7 +60,7 @@ public class SlidingOverlaysQueue implements SlidingOverlay.SlidingListener{
60 60
 
61 61
     @Override
62 62
     public void onSlidingOverlayShown() {
63
-        Integer autoDismissTimerSec = queue.peek().getAutoDismissTimerSec();
63
+        Integer autoDismissTimerSec = queue.peek() == null ? null : queue.peek().getAutoDismissTimerSec();
64 64
 
65 65
         if (autoDismissTimerSec != null || pendingHide || queue.size() > 1) {
66 66
             int autoDismissDuration = autoDismissTimerSec != null
@@ -75,7 +75,9 @@ public class SlidingOverlaysQueue implements SlidingOverlay.SlidingListener{
75 75
                     NavigationApplication.instance.runOnMainThread(new Runnable() {
76 76
                         @Override
77 77
                         public void run() {
78
-                            queue.peek().hide();
78
+                            if(queue.peek() != null) {
79
+                                queue.peek().hide();
80
+                            }
79 81
                         }
80 82
                     });
81 83
                 }