react-native-fast-image 8.6.29 → 8.6.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,7 @@ public class FastImageSource extends ImageSource {
17
17
  private static final String ANDROID_RESOURCE_SCHEME = "android.resource";
18
18
  private static final String ANDROID_CONTENT_SCHEME = "content";
19
19
  private static final String LOCAL_FILE_SCHEME = "file";
20
+ private static final String ASSET_SCHEME = "asset";
20
21
  private final Headers mHeaders;
21
22
  private Uri mUri;
22
23
 
@@ -40,6 +41,10 @@ public class FastImageSource extends ImageSource {
40
41
  return LOCAL_FILE_SCHEME.equals(uri.getScheme());
41
42
  }
42
43
 
44
+ public static boolean isAssetUri(Uri uri) {
45
+ return ASSET_SCHEME.equals(uri.getScheme());
46
+ }
47
+
43
48
  public FastImageSource(Context context, String source) {
44
49
  this(context, source, null);
45
50
  }
@@ -62,6 +67,12 @@ public class FastImageSource extends ImageSource {
62
67
  // glide can understand the uri.
63
68
  mUri = Uri.parse(mUri.toString().replace("res:/", ANDROID_RESOURCE_SCHEME + "://" + context.getPackageName() + "/"));
64
69
  }
70
+
71
+ if (isAssetUri(mUri) && mUri.getPath() != null) {
72
+ // Convert asset:/ (a file in the app's assets, as React Native's
73
+ // Image supports) to file:///android_asset/, which Glide loads.
74
+ mUri = Uri.parse(LOCAL_FILE_SCHEME + ":///android_asset" + mUri.getPath());
75
+ }
65
76
  }
66
77
 
67
78
 
@@ -55,16 +55,9 @@ class FastImageViewModule extends ReactContextBaseJavaModule {
55
55
 
56
56
  Glide
57
57
  .with(activity.getApplicationContext())
58
- // This will make this work for remote and local images. e.g.
59
- // - file:///
60
- // - content://
61
- // - res:/
62
- // - android.resource://
63
- // - data:image/png;base64
64
- .load(
65
- imageSource.isBase64Resource() ? imageSource.getSource() :
66
- imageSource.isResource() ? imageSource.getUri() : imageSource.getGlideUrl()
67
- )
58
+ // Load it the way the view does, so local images
59
+ // (file://, content://, asset:/) work too.
60
+ .load(imageSource.getSourceForLoad())
68
61
  .apply(FastImageViewConverter.getOptions(activity, imageSource, source))
69
62
  .preload();
70
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-fast-image",
3
- "version": "8.6.29",
3
+ "version": "8.6.30",
4
4
  "description": "🚩 FastImage, performant React Native image component.",
5
5
  "keywords": [
6
6
  "cache",