react-native-fast-image 8.6.29 → 8.6.31
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.
package/android/build.gradle
CHANGED
|
@@ -74,6 +74,8 @@ dependencies {
|
|
|
74
74
|
//noinspection GradleDynamicVersion
|
|
75
75
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
76
76
|
implementation "com.github.bumptech.glide:glide:${glideVersion}"
|
|
77
|
+
// FastImageGlideModule and FastImageOkHttpProgressGlideModule use @GlideModule.
|
|
78
|
+
implementation "com.github.bumptech.glide:annotations:${glideVersion}"
|
|
77
79
|
implementation "com.github.bumptech.glide:okhttp3-integration:${glideVersion}"
|
|
78
80
|
annotationProcessor "com.github.bumptech.glide:compiler:${glideVersion}"
|
|
79
81
|
}
|
|
@@ -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
|
-
//
|
|
59
|
-
//
|
|
60
|
-
|
|
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
|
}
|