Skip to content

Commit

Permalink
fix: null exception in FastImageViewManager.java (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
hungvxt authored Sep 27, 2021
1 parent 8950a38 commit a7a8643
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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 @@ -58,9 +59,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 Down Expand Up @@ -97,9 +96,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 @@ -149,9 +146,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 @@ -244,4 +239,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);
}
}
}

0 comments on commit a7a8643

Please sign in to comment.