Browse Source

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

Varun Gupta 7 years ago
parent
commit
f46cfa8205

+ 5
- 3
android/app/src/main/java/com/reactnativenavigation/views/slidingOverlay/SlidingOverlaysQueue.java View File

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