react-native-fast-image 8.6.34 → 8.6.35
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.
|
@@ -38,9 +38,6 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> imple
|
|
|
38
38
|
static final String REACT_ON_PROGRESS_EVENT = "onFastImageProgress";
|
|
39
39
|
private static final Map<String, List<FastImageViewWithUrl>> VIEWS_FOR_URLS = new WeakHashMap<>();
|
|
40
40
|
|
|
41
|
-
@Nullable
|
|
42
|
-
private RequestManager requestManager = null;
|
|
43
|
-
|
|
44
41
|
@NonNull
|
|
45
42
|
@Override
|
|
46
43
|
public String getName() {
|
|
@@ -50,6 +47,10 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> imple
|
|
|
50
47
|
@NonNull
|
|
51
48
|
@Override
|
|
52
49
|
protected FastImageViewWithUrl createViewInstance(@NonNull ThemedReactContext reactContext) {
|
|
50
|
+
// Each view keeps the RequestManager for its own Activity. A single one
|
|
51
|
+
// shared by all views kept the last view's Activity alive after it was
|
|
52
|
+
// destroyed, and gave views another Activity's manager (#492).
|
|
53
|
+
RequestManager requestManager = null;
|
|
53
54
|
if (isValidContextForGlide(reactContext)) {
|
|
54
55
|
requestManager = Glide.with(reactContext);
|
|
55
56
|
} else if (getActivityFromContext(reactContext) == null) {
|
|
@@ -59,7 +60,7 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> imple
|
|
|
59
60
|
requestManager = Glide.with(reactContext.getApplicationContext());
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
return new FastImageViewWithUrl(reactContext);
|
|
63
|
+
return new FastImageViewWithUrl(reactContext, requestManager);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
@ReactProp(name = "source")
|
|
@@ -92,7 +93,7 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> imple
|
|
|
92
93
|
@Override
|
|
93
94
|
public void onDropViewInstance(@NonNull FastImageViewWithUrl view) {
|
|
94
95
|
// This will cancel existing requests.
|
|
95
|
-
view.clearView(requestManager);
|
|
96
|
+
view.clearView(view.requestManager);
|
|
96
97
|
|
|
97
98
|
// Same key as when the view was tracked (toStringUrl, not toString,
|
|
98
99
|
// which differ for urls that need escaping).
|
|
@@ -201,6 +202,6 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> imple
|
|
|
201
202
|
@Override
|
|
202
203
|
protected void onAfterUpdateTransaction(@NonNull FastImageViewWithUrl view) {
|
|
203
204
|
super.onAfterUpdateTransaction(view);
|
|
204
|
-
view.onAfterUpdate(this, requestManager, VIEWS_FOR_URLS);
|
|
205
|
+
view.onAfterUpdate(this, view.requestManager, VIEWS_FOR_URLS);
|
|
205
206
|
}
|
|
206
207
|
}
|
|
@@ -32,9 +32,13 @@ class FastImageViewWithUrl extends AppCompatImageView {
|
|
|
32
32
|
private Drawable mDefaultSource = null;
|
|
33
33
|
|
|
34
34
|
public GlideUrl glideUrl;
|
|
35
|
+
// Null when the view was created in a destroyed Activity (nothing loads).
|
|
36
|
+
@Nullable
|
|
37
|
+
final RequestManager requestManager;
|
|
35
38
|
|
|
36
|
-
public FastImageViewWithUrl(Context context) {
|
|
39
|
+
public FastImageViewWithUrl(Context context, @Nullable RequestManager requestManager) {
|
|
37
40
|
super(context);
|
|
41
|
+
this.requestManager = requestManager;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
public void setSource(@Nullable ReadableMap source) {
|