浏览代码

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 年前
父节点
当前提交
c82bc57d58
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 2 次插入3 次删除
  1. 2
    3
      lib/android/app/src/main/java/com/reactnativenavigation/utils/ImageLoader.java

+ 2
- 3
lib/android/app/src/main/java/com/reactnativenavigation/utils/ImageLoader.java 查看文件

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