react-native-fast-image 8.6.26 → 8.6.28
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.
|
@@ -94,15 +94,9 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> imple
|
|
|
94
94
|
// This will cancel existing requests.
|
|
95
95
|
view.clearView(requestManager);
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
List<FastImageViewWithUrl> viewsForKey = VIEWS_FOR_URLS.get(key);
|
|
101
|
-
if (viewsForKey != null) {
|
|
102
|
-
viewsForKey.remove(view);
|
|
103
|
-
if (viewsForKey.size() == 0) VIEWS_FOR_URLS.remove(key);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
97
|
+
// Same key as when the view was tracked (toStringUrl, not toString,
|
|
98
|
+
// which differ for urls that need escaping).
|
|
99
|
+
view.untrackUrl(VIEWS_FOR_URLS);
|
|
106
100
|
|
|
107
101
|
super.onDropViewInstance(view);
|
|
108
102
|
}
|
|
@@ -72,9 +72,7 @@ class FastImageViewWithUrl extends AppCompatImageView {
|
|
|
72
72
|
// Cancel existing requests.
|
|
73
73
|
clearView(requestManager);
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
FastImageOkHttpProgressGlideModule.forget(glideUrl.toStringUrl());
|
|
77
|
-
}
|
|
75
|
+
untrackUrl(viewsForUrlsMap);
|
|
78
76
|
|
|
79
77
|
// Clear the image.
|
|
80
78
|
setImageDrawable(null);
|
|
@@ -103,9 +101,7 @@ class FastImageViewWithUrl extends AppCompatImageView {
|
|
|
103
101
|
// Cancel existing requests.
|
|
104
102
|
clearView(requestManager);
|
|
105
103
|
|
|
106
|
-
|
|
107
|
-
FastImageOkHttpProgressGlideModule.forget(glideUrl.toStringUrl());
|
|
108
|
-
}
|
|
104
|
+
untrackUrl(viewsForUrlsMap);
|
|
109
105
|
setImageDrawable(mDefaultSource);
|
|
110
106
|
return;
|
|
111
107
|
}
|
|
@@ -113,12 +109,17 @@ class FastImageViewWithUrl extends AppCompatImageView {
|
|
|
113
109
|
// `imageSource` may be null and we still continue, if `defaultSource` is not null
|
|
114
110
|
final GlideUrl glideUrl = imageSource == null ? null : imageSource.getGlideUrl();
|
|
115
111
|
|
|
112
|
+
String key = glideUrl == null ? null : glideUrl.toStringUrl();
|
|
113
|
+
|
|
114
|
+
// Loading a different url: stop tracking the old one.
|
|
115
|
+
if (this.glideUrl != null && !this.glideUrl.toStringUrl().equals(key)) {
|
|
116
|
+
untrackUrl(viewsForUrlsMap);
|
|
117
|
+
}
|
|
118
|
+
|
|
116
119
|
// Cancel existing request.
|
|
117
120
|
this.glideUrl = glideUrl;
|
|
118
121
|
clearView(requestManager);
|
|
119
122
|
|
|
120
|
-
String key = glideUrl == null ? null : glideUrl.toStringUrl();
|
|
121
|
-
|
|
122
123
|
if (glideUrl != null) {
|
|
123
124
|
FastImageOkHttpProgressGlideModule.expect(key, manager);
|
|
124
125
|
List<FastImageViewWithUrl> viewsForKey = viewsForUrlsMap.get(key);
|
|
@@ -163,6 +164,24 @@ class FastImageViewWithUrl extends AppCompatImageView {
|
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
|
|
167
|
+
// Removes this view from the list of views for its current url (used to send
|
|
168
|
+
// progress events), which otherwise kept it, and its Activity, alive after
|
|
169
|
+
// its source changed (#384). The url's progress listener is only forgotten
|
|
170
|
+
// when no other view uses it.
|
|
171
|
+
void untrackUrl(@Nonnull Map<String, List<FastImageViewWithUrl>> viewsForUrlsMap) {
|
|
172
|
+
if (glideUrl == null) return;
|
|
173
|
+
String key = glideUrl.toStringUrl();
|
|
174
|
+
List<FastImageViewWithUrl> viewsForKey = viewsForUrlsMap.get(key);
|
|
175
|
+
if (viewsForKey != null) {
|
|
176
|
+
viewsForKey.remove(this);
|
|
177
|
+
if (viewsForKey.isEmpty()) viewsForUrlsMap.remove(key);
|
|
178
|
+
}
|
|
179
|
+
if (viewsForKey == null || viewsForKey.isEmpty()) {
|
|
180
|
+
FastImageOkHttpProgressGlideModule.forget(key);
|
|
181
|
+
}
|
|
182
|
+
glideUrl = null;
|
|
183
|
+
}
|
|
184
|
+
|
|
166
185
|
public void clearView(@Nullable RequestManager requestManager) {
|
|
167
186
|
if (requestManager != null && getTag() != null && getTag() instanceof Request) {
|
|
168
187
|
requestManager.clear(this);
|
|
@@ -55,7 +55,9 @@
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
- (void) setOnFastImageLoadStart: (RCTDirectEventBlock)onFastImageLoadStart {
|
|
58
|
-
|
|
58
|
+
// Send it for a load that has already started. When a reload is pending
|
|
59
|
+
// (e.g. source set in the same update), reloadImage sends it.
|
|
60
|
+
if (_source && !_needsReload && !self.hasSentOnLoadStart && onFastImageLoadStart) {
|
|
59
61
|
_onFastImageLoadStart = onFastImageLoadStart;
|
|
60
62
|
onFastImageLoadStart(@{});
|
|
61
63
|
self.hasSentOnLoadStart = YES;
|