Browse Source

Fix loading local images (#4769)

When loading local image resource (images in Drawable folder), RNN mistakingly tried to load the image as a js asset even if it successfully loaded the local image.
Guy Carmeli 6 years ago
parent
commit
c82bc57d58
No account linked to committer's email address

+ 2
- 3
lib/android/app/src/main/java/com/reactnativenavigation/utils/ImageLoader.java View File

66
     @NonNull
66
     @NonNull
67
     private Drawable getDrawable(Context context, String source) throws IOException {
67
     private Drawable getDrawable(Context context, String source) throws IOException {
68
         Drawable drawable;
68
         Drawable drawable;
69
-
70
         if (isLocalFile(Uri.parse(source))) {
69
         if (isLocalFile(Uri.parse(source))) {
71
             drawable = loadFile(source);
70
             drawable = loadFile(source);
72
         } else {
71
         } else {
73
             drawable = loadResource(source);
72
             drawable = loadResource(source);
74
-            if (drawable == null || NavigationApplication.instance.isDebug()) {
73
+            if (drawable == null && NavigationApplication.instance.isDebug()) {
75
                 drawable = readJsDevImage(context, source);
74
                 drawable = readJsDevImage(context, source);
76
             }
75
             }
77
         }
76
         }
78
-
77
+        if (drawable == null) throw new RuntimeException("Could not load image " + source);
79
         return drawable;
78
         return drawable;
80
     }
79
     }
81
 
80