Kaynağa Gözat

NPE screenParams before setting rootBackgroundImageName

Guy Carmeli 6 yıl önce
ebeveyn
işleme
d96f091e40

+ 5
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java Dosyayı Görüntüle

@@ -101,13 +101,17 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
101 101
         if (hasBackgroundColor()) {
102 102
             layout.asView().setBackgroundColor(AppStyle.appStyle.screenBackgroundColor.getColor());
103 103
         }
104
-        String rootBackgroundImageName = activityParams.screenParams.styleParams.rootBackgroundImageName;
104
+        String rootBackgroundImageName = getRootBackgroundImageName();
105 105
         if (rootBackgroundImageName != null) {
106 106
             layout.asView().setBackgroundResource(this.getResources().getIdentifier(rootBackgroundImageName, "drawable", this.getPackageName()));
107 107
         }
108 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 115
     private boolean hasBackgroundColor() {
112 116
         return AppStyle.appStyle.screenBackgroundColor != null &&
113 117
                 AppStyle.appStyle.screenBackgroundColor.hasColor();