From e562fb678c27db981b3661bf73990b99920ea807 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 21 Mar 2023 15:58:16 -0400 Subject: [PATCH] Try harder in the Android backend to load images in the main (UI) thread --- .../microsoft/maui/glide/MauiCustomViewTarget.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Core/AndroidNative/maui/src/main/java/com/microsoft/maui/glide/MauiCustomViewTarget.java b/src/Core/AndroidNative/maui/src/main/java/com/microsoft/maui/glide/MauiCustomViewTarget.java index 765afdb5060b..8c96bdfc8219 100644 --- a/src/Core/AndroidNative/maui/src/main/java/com/microsoft/maui/glide/MauiCustomViewTarget.java +++ b/src/Core/AndroidNative/maui/src/main/java/com/microsoft/maui/glide/MauiCustomViewTarget.java @@ -27,7 +27,7 @@ public MauiCustomViewTarget(@NonNull ImageView view, ImageLoaderCallback callbac @Override protected void onResourceCleared(@Nullable Drawable placeholder) { - this.view.setImageDrawable(placeholder); + post(() -> this.view.setImageDrawable(placeholder)); } @Override @@ -46,11 +46,13 @@ public void onResourceReady(@NonNull Drawable resource, @Nullable Transition { + // set the image + this.view.setImageDrawable(resource); - // trigger the callback out of this target - post(() -> callback.onComplete(true, resource, this::clear)); + // trigger the callback out of this target + callback.onComplete(true, resource, this::clear) + }); } private void post(Runnable runnable) {