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

Don't let Glide clear the old image on Android ImageView unless we get an error #23313

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -17,25 +17,30 @@
public class MauiCustomViewTarget extends CustomViewTarget<ImageView, Drawable> {
private final ImageLoaderCallback callback;
private boolean completed;
private boolean cleared;

public MauiCustomViewTarget(@NonNull ImageView view, ImageLoaderCallback callback) {
super(view);

this.completed = false;
this.callback = callback;
}

@Override
protected void onResourceCleared(@Nullable Drawable placeholder) {
this.view.setImageDrawable(placeholder);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placeholder is always null here because we never set it on the configuration

this.cleared = true;
}

@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
if (completed)
return;

this.completed = true;

if (this.cleared) {
this.view.setImageDrawable(null);
}
jonathanpeppers marked this conversation as resolved.
Show resolved Hide resolved

// trigger the callback out of this target
post(() -> callback.onComplete(false, errorDrawable, this::clear));
}
Expand All @@ -44,6 +49,7 @@ public void onLoadFailed(@Nullable Drawable errorDrawable) {
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
if (completed)
return;

this.completed = true;

post(() -> {
Expand Down
Binary file modified src/Core/src/maui.aar
Binary file not shown.