瀏覽代碼

Fix npe in BottomTabswhen appStyle is undefined. Again.

Guy Carmeli 8 年之前
父節點
當前提交
a545549420
共有 1 個文件被更改,包括 10 次插入5 次删除
  1. 10
    5
      android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java

+ 10
- 5
android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java 查看文件

@@ -82,14 +82,19 @@ public class BottomTabs extends AHBottomNavigation {
82 82
     }
83 83
 
84 84
     private void setStyle() {
85
-        if (AppStyle.appStyle == null) {
86
-            return;
87
-        }
88
-        if (AppStyle.appStyle.bottomTabBadgeBackgroundColor.hasColor()) {
85
+        if (hasBadgeBackgroundColor()) {
89 86
             setNotificationBackgroundColor(AppStyle.appStyle.bottomTabBadgeBackgroundColor.getColor());
90 87
         }
91
-        if (AppStyle.appStyle.bottomTabBadgeTextColor.hasColor()) {
88
+        if (hasBadgeTextColor()) {
92 89
             setNotificationTextColor(AppStyle.appStyle.bottomTabBadgeTextColor.getColor());
93 90
         }
94 91
     }
92
+
93
+    private boolean hasBadgeTextColor() {
94
+        return AppStyle.appStyle.bottomTabBadgeTextColor != null && AppStyle.appStyle.bottomTabBadgeTextColor.hasColor();
95
+    }
96
+
97
+    private boolean hasBadgeBackgroundColor() {
98
+        return AppStyle.appStyle.bottomTabBadgeBackgroundColor != null && AppStyle.appStyle.bottomTabBadgeBackgroundColor.hasColor();
99
+    }
95 100
 }