From 5d2894e442dc3d239b4dc9cb25dca455f7d8bc6e Mon Sep 17 00:00:00 2001 From: Pavan Tiwari Date: Fri, 17 Jul 2020 11:36:21 -0700 Subject: [PATCH] fix(android): remove explicit use of UI thread (#698) No need to send events via UI thread. This causes app to use main thread unnecessary that may result in a ARN exception. --- .../FastImageOkHttpProgressGlideModule.java | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java b/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java index 2214f04af..e659a616e 100644 --- a/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java +++ b/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java @@ -1,8 +1,6 @@ package com.dylanvann.fastimage; import android.content.Context; -import android.os.Handler; -import android.os.Looper; import androidx.annotation.NonNull; import com.bumptech.glide.Glide; @@ -82,12 +80,6 @@ private static class DispatchingProgressListener implements ResponseProgressList private final Map LISTENERS = new WeakHashMap<>(); private final Map PROGRESSES = new HashMap<>(); - private final Handler handler; - - DispatchingProgressListener() { - this.handler = new Handler(Looper.getMainLooper()); - } - void forget(String key) { LISTENERS.remove(key); PROGRESSES.remove(key); @@ -107,12 +99,7 @@ public void update(final String key, final long bytesRead, final long contentLen forget(key); } if (needsDispatch(key, bytesRead, contentLength, listener.getGranularityPercentage())) { - handler.post(new Runnable() { - @Override - public void run() { - listener.onProgress(key, bytesRead, contentLength); - } - }); + listener.onProgress(key, bytesRead, contentLength); } }