Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FastImageViewManager.java #423

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.request.Request;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
Expand Down Expand Up @@ -56,9 +57,7 @@ protected FastImageViewWithUrl createViewInstance(ThemedReactContext reactContex
public void setSrc(FastImageViewWithUrl view, @Nullable ReadableMap source) {
if (source == null || !source.hasKey("uri") || isNullOrEmpty(source.getString("uri"))) {
// Cancel existing requests.
if (requestManager != null) {
requestManager.clear(view);
}
clearView(view);

if (view.glideUrl != null) {
FastImageOkHttpProgressGlideModule.forget(view.glideUrl.toStringUrl());
Expand All @@ -74,9 +73,7 @@ public void setSrc(FastImageViewWithUrl view, @Nullable ReadableMap source) {

// Cancel existing request.
view.glideUrl = glideUrl;
if (requestManager != null) {
requestManager.clear(view);
}
clearView(view);

String key = glideUrl.toStringUrl();
FastImageOkHttpProgressGlideModule.expect(key, this);
Expand Down Expand Up @@ -117,9 +114,7 @@ public void setResizeMode(FastImageViewWithUrl view, String resizeMode) {
@Override
public void onDropViewInstance(FastImageViewWithUrl view) {
// This will cancel existing requests.
if (requestManager != null) {
requestManager.clear(view);
}
clearView(view);

if (view.glideUrl != null) {
final String key = view.glideUrl.toString();
Expand Down Expand Up @@ -201,4 +196,10 @@ private static boolean isActivityDestroyed(Activity activity) {
}

}

private void clearView(FastImageViewWithUrl view) {
if (requestManager != null && view != null && view.getTag() != null && view.getTag() instanceof Request) {
requestManager.clear(view);
}
}
}