Browse Source

NPE screenParams before setting rootBackgroundImageName

Guy Carmeli 6 years ago
parent
commit
d96f091e40

+ 5
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java View File

101
         if (hasBackgroundColor()) {
101
         if (hasBackgroundColor()) {
102
             layout.asView().setBackgroundColor(AppStyle.appStyle.screenBackgroundColor.getColor());
102
             layout.asView().setBackgroundColor(AppStyle.appStyle.screenBackgroundColor.getColor());
103
         }
103
         }
104
-        String rootBackgroundImageName = activityParams.screenParams.styleParams.rootBackgroundImageName;
104
+        String rootBackgroundImageName = getRootBackgroundImageName();
105
         if (rootBackgroundImageName != null) {
105
         if (rootBackgroundImageName != null) {
106
             layout.asView().setBackgroundResource(this.getResources().getIdentifier(rootBackgroundImageName, "drawable", this.getPackageName()));
106
             layout.asView().setBackgroundResource(this.getResources().getIdentifier(rootBackgroundImageName, "drawable", this.getPackageName()));
107
         }
107
         }
108
         setContentView(layout.asView());
108
         setContentView(layout.asView());
109
     }
109
     }
110
 
110
 
111
+    private String getRootBackgroundImageName() {
112
+        return activityParams.screenParams == null ? null : activityParams.screenParams.styleParams.rootBackgroundImageName;
113
+    }
114
+
111
     private boolean hasBackgroundColor() {
115
     private boolean hasBackgroundColor() {
112
         return AppStyle.appStyle.screenBackgroundColor != null &&
116
         return AppStyle.appStyle.screenBackgroundColor != null &&
113
                 AppStyle.appStyle.screenBackgroundColor.hasColor();
117
                 AppStyle.appStyle.screenBackgroundColor.hasColor();