react-native-fast-image 8.6.24 → 8.6.26
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.
|
@@ -52,6 +52,11 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> imple
|
|
|
52
52
|
protected FastImageViewWithUrl createViewInstance(@NonNull ThemedReactContext reactContext) {
|
|
53
53
|
if (isValidContextForGlide(reactContext)) {
|
|
54
54
|
requestManager = Glide.with(reactContext);
|
|
55
|
+
} else if (getActivityFromContext(reactContext) == null) {
|
|
56
|
+
// Not in an Activity (e.g. a root view created with the application
|
|
57
|
+
// context): load with the application context, instead of leaving
|
|
58
|
+
// requestManager null and never loading (#520).
|
|
59
|
+
requestManager = Glide.with(reactContext.getApplicationContext());
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
return new FastImageViewWithUrl(reactContext);
|
|
@@ -81,7 +86,7 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl> imple
|
|
|
81
86
|
@ReactProp(name = "resizeMode")
|
|
82
87
|
public void setResizeMode(FastImageViewWithUrl view, String resizeMode) {
|
|
83
88
|
final FastImageViewWithUrl.ScaleType scaleType = FastImageViewConverter.getScaleType(resizeMode);
|
|
84
|
-
view.
|
|
89
|
+
view.setResizeMode(scaleType);
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
@Override
|
|
@@ -48,6 +48,14 @@ class FastImageViewWithUrl extends AppCompatImageView {
|
|
|
48
48
|
mDefaultSource = source;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
// Glide crops or fits the bitmap for the scale type when it loads, so a
|
|
52
|
+
// new resizeMode needs a reload to take effect (#762).
|
|
53
|
+
public void setResizeMode(ScaleType scaleType) {
|
|
54
|
+
if (scaleType == getScaleType()) return;
|
|
55
|
+
setScaleType(scaleType);
|
|
56
|
+
mNeedsReload = true;
|
|
57
|
+
}
|
|
58
|
+
|
|
51
59
|
@SuppressLint("CheckResult")
|
|
52
60
|
public void onAfterUpdate(
|
|
53
61
|
@Nonnull FastImageViewManager manager,
|
|
@@ -55,6 +63,9 @@ class FastImageViewWithUrl extends AppCompatImageView {
|
|
|
55
63
|
@Nonnull Map<String, List<FastImageViewWithUrl>> viewsForUrlsMap) {
|
|
56
64
|
if (!mNeedsReload)
|
|
57
65
|
return;
|
|
66
|
+
// Only reload for changes that affect the request (source,
|
|
67
|
+
// defaultSource, resizeMode), not for every prop update.
|
|
68
|
+
mNeedsReload = false;
|
|
58
69
|
|
|
59
70
|
// Nothing to show.
|
|
60
71
|
if (mSource == null && mDefaultSource == null) {
|