瀏覽代碼

Add null check to ViewVisibilityChecker

relates to #1555
Guy Carmeli 8 年之前
父節點
當前提交
60608b08ae
共有 1 個檔案被更改,包括 5 行新增1 行删除
  1. 5
    1
      android/app/src/main/java/com/reactnativenavigation/utils/ViewVisibilityChecker.java

+ 5
- 1
android/app/src/main/java/com/reactnativenavigation/utils/ViewVisibilityChecker.java 查看文件

1
 package com.reactnativenavigation.utils;
1
 package com.reactnativenavigation.utils;
2
 
2
 
3
+import android.support.annotation.Nullable;
3
 import android.view.View;
4
 import android.view.View;
4
 
5
 
5
 import com.reactnativenavigation.views.ContentView;
6
 import com.reactnativenavigation.views.ContentView;
6
 
7
 
7
 public class ViewVisibilityChecker {
8
 public class ViewVisibilityChecker {
8
 
9
 
9
-    public static boolean check(View view) {
10
+    public static boolean check(@Nullable View view) {
11
+        if (view == null) {
12
+            return false;
13
+        }
10
         final int top = getTopRelativeToContentView(view);
14
         final int top = getTopRelativeToContentView(view);
11
         final int scrollYInScreen = getScrollYInScreen(view);
15
         final int scrollYInScreen = getScrollYInScreen(view);
12
         return top + view.getHeight() > scrollYInScreen;
16
         return top + view.getHeight() > scrollYInScreen;