react-native-fast-image 8.6.13 → 8.6.15
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.dylanvann.fastimage;
|
|
2
2
|
|
|
3
3
|
import android.app.Activity;
|
|
4
|
+
import android.util.Log;
|
|
4
5
|
|
|
5
6
|
import androidx.annotation.NonNull;
|
|
6
7
|
|
|
@@ -17,6 +18,7 @@ import com.facebook.react.views.imagehelper.ImageSource;
|
|
|
17
18
|
class FastImageViewModule extends ReactContextBaseJavaModule {
|
|
18
19
|
|
|
19
20
|
private static final String REACT_CLASS = "FastImageView";
|
|
21
|
+
private static final String TAG = "FastImage";
|
|
20
22
|
|
|
21
23
|
FastImageViewModule(ReactApplicationContext reactContext) {
|
|
22
24
|
super(reactContext);
|
|
@@ -38,8 +40,18 @@ class FastImageViewModule extends ReactContextBaseJavaModule {
|
|
|
38
40
|
for (int i = 0; i < sources.size(); i++) {
|
|
39
41
|
final ReadableMap source = sources.getMap(i);
|
|
40
42
|
// Skip sources without a uri (Glide throws on an empty url).
|
|
41
|
-
|
|
43
|
+
// preload has no way to report errors, so log them.
|
|
44
|
+
if (!FastImageViewConverter.hasUri(source)) {
|
|
45
|
+
Log.w(TAG, "preload: skipping a source without a uri");
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
42
48
|
final FastImageSource imageSource = FastImageViewConverter.getImageSource(activity, source);
|
|
49
|
+
// Also skip a uri that can't be resolved (e.g. a relative path),
|
|
50
|
+
// which resolves to an empty one. The view reports it as an error.
|
|
51
|
+
if (imageSource.getUri().toString().isEmpty()) {
|
|
52
|
+
Log.w(TAG, "preload: skipping a uri that can't be resolved: " + source.getString("uri"));
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
43
55
|
|
|
44
56
|
Glide
|
|
45
57
|
.with(activity.getApplicationContext())
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
@property(nonatomic, assign) BOOL needsReload;
|
|
12
12
|
|
|
13
13
|
@property(nonatomic, strong) NSDictionary* onLoadEvent;
|
|
14
|
+
// The image before tinting, kept while a tint is applied so the tint can be
|
|
15
|
+
// changed or removed. nil when there's no tint (super.image is untinted).
|
|
16
|
+
@property(nonatomic, strong) UIImage* untintedImage;
|
|
14
17
|
|
|
15
18
|
@end
|
|
16
19
|
|
|
@@ -63,11 +66,11 @@
|
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
- (void) setImageColor: (UIColor*)imageColor {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
_imageColor = imageColor;
|
|
70
|
+
// Re-apply to the untinted image, so the tint can change or be removed.
|
|
71
|
+
UIImage* image = self.untintedImage ?: super.image;
|
|
72
|
+
if (image) {
|
|
73
|
+
[self setImage: image];
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
|
|
@@ -110,8 +113,10 @@
|
|
|
110
113
|
|
|
111
114
|
- (void) setImage: (UIImage*)image {
|
|
112
115
|
if (self.imageColor != nil) {
|
|
116
|
+
self.untintedImage = image;
|
|
113
117
|
super.image = [self makeImage: image withTint: self.imageColor];
|
|
114
118
|
} else {
|
|
119
|
+
self.untintedImage = nil;
|
|
115
120
|
super.image = image;
|
|
116
121
|
}
|
|
117
122
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import "FFFastImageViewManager.h"
|
|
2
2
|
#import "FFFastImageView.h"
|
|
3
|
+
#import <React/RCTLog.h>
|
|
3
4
|
|
|
4
5
|
#import <SDWebImage/SDImageCache.h>
|
|
5
6
|
#import <SDWebImage/SDWebImagePrefetcher.h>
|
|
@@ -30,6 +31,8 @@ RCT_EXPORT_METHOD(preload:(nonnull NSArray<FFFastImageSource *> *)sources)
|
|
|
30
31
|
// Skip sources without a url (an empty, missing or null uri). NSArray can't
|
|
31
32
|
// hold nil, so adding one throws and crashes the app.
|
|
32
33
|
if (!source.url) {
|
|
34
|
+
// preload has no way to report errors, so log it.
|
|
35
|
+
RCTLogWarn(@"FastImage.preload: skipping a source without a valid uri");
|
|
33
36
|
return;
|
|
34
37
|
}
|
|
35
38
|
[source.headers enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString* header, BOOL *stop) {
|