Skip to content

Commit

Permalink
fix(android): remove explicit use of UI thread (#698)
Browse files Browse the repository at this point in the history
No need to send events via UI thread. This causes app to use main thread unnecessary that may result in a ARN exception.
  • Loading branch information
pawan52tiwari authored Jul 17, 2020
1 parent 250b4e5 commit 5d2894e
Showing 1 changed file with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -82,12 +80,6 @@ private static class DispatchingProgressListener implements ResponseProgressList
private final Map<String, FastImageProgressListener> LISTENERS = new WeakHashMap<>();
private final Map<String, Long> PROGRESSES = new HashMap<>();

private final Handler handler;

DispatchingProgressListener() {
this.handler = new Handler(Looper.getMainLooper());
}

void forget(String key) {
LISTENERS.remove(key);
PROGRESSES.remove(key);
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 5d2894e

Please sign in to comment.