Browse Source

Null check when parsing strings

Mostly relevant to malformed icons where for some reason, requiring an image results in null.
Guy Carmeli 6 years ago
parent
commit
eda4b9ce0a

+ 4
- 2
lib/android/app/src/main/java/com/reactnativenavigation/parse/parsers/TextParser.java View File

@@ -5,8 +5,10 @@ import com.reactnativenavigation.parse.params.Text;
5 5
 
6 6
 import org.json.JSONObject;
7 7
 
8
+import javax.annotation.*;
9
+
8 10
 public class TextParser {
9
-    public static Text parse(JSONObject json, String text) {
10
-        return json.has(text) ? new Text(json.optString(text)) : new NullText();
11
+    public static Text parse(@Nullable JSONObject json, String text) {
12
+        return json != null && json.has(text) ? new Text(json.optString(text)) : new NullText();
11 13
     }
12 14
 }