Browse Source

handle null bundle in parsers

Guy Carmeli 8 years ago
parent
commit
d2cc5e45f3

+ 3
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/ColorParser.java View File

7
 public class ColorParser {
7
 public class ColorParser {
8
     @ColorInt
8
     @ColorInt
9
     public static int parse(String str) {
9
     public static int parse(String str) {
10
+        if (str == null) {
11
+            return -1;
12
+        }
10
         return Color.parseColor(str);
13
         return Color.parseColor(str);
11
     }
14
     }
12
 }
15
 }

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/ScreenStyleParamsParser.java View File

7
 public class ScreenStyleParamsParser {
7
 public class ScreenStyleParamsParser {
8
     public static ScreenStyleParams parse(Bundle params) {
8
     public static ScreenStyleParams parse(Bundle params) {
9
         ScreenStyleParams result = new ScreenStyleParams();
9
         ScreenStyleParams result = new ScreenStyleParams();
10
+        if (params == null) {
11
+            return result;
12
+        }
13
+
10
         result.statusBarColor = ColorParser.parse(params.getString("statusBarColor"));
14
         result.statusBarColor = ColorParser.parse(params.getString("statusBarColor"));
11
         result.topBarColor = ColorParser.parse(params.getString("topBarColor"));
15
         result.topBarColor = ColorParser.parse(params.getString("topBarColor"));
12
         result.navigationBarColor = ColorParser.parse(params.getString("navigationBarColor"));
16
         result.navigationBarColor = ColorParser.parse(params.getString("navigationBarColor"));

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/TitleBarButtonParamsParser.java View File

11
 public class TitleBarButtonParamsParser {
11
 public class TitleBarButtonParamsParser {
12
     public static List<TitleBarButtonParams> parse(Bundle params) {
12
     public static List<TitleBarButtonParams> parse(Bundle params) {
13
         List<TitleBarButtonParams> result = new ArrayList<>();
13
         List<TitleBarButtonParams> result = new ArrayList<>();
14
+        if (params == null) {
15
+            return result;
16
+        }
17
+
14
         for (String key : params.keySet()) {
18
         for (String key : params.keySet()) {
15
             result.add(parseItem(params.getBundle(key)));
19
             result.add(parseItem(params.getBundle(key)));
16
         }
20
         }