Skip to content

Commit 5d2894e

Browse files
fix(android): remove explicit use of UI thread (DylanVann#698)
No need to send events via UI thread. This causes app to use main thread unnecessary that may result in a ARN exception.
1 parent 250b4e5 commit 5d2894e

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.dylanvann.fastimage;
22

33
import android.content.Context;
4-
import android.os.Handler;
5-
import android.os.Looper;
64
import androidx.annotation.NonNull;
75

86
import com.bumptech.glide.Glide;
@@ -82,12 +80,6 @@ private static class DispatchingProgressListener implements ResponseProgressList
8280
private final Map<String, FastImageProgressListener> LISTENERS = new WeakHashMap<>();
8381
private final Map<String, Long> PROGRESSES = new HashMap<>();
8482

85-
private final Handler handler;
86-
87-
DispatchingProgressListener() {
88-
this.handler = new Handler(Looper.getMainLooper());
89-
}
90-
9183
void forget(String key) {
9284
LISTENERS.remove(key);
9385
PROGRESSES.remove(key);
@@ -107,12 +99,7 @@ public void update(final String key, final long bytesRead, final long contentLen
10799
forget(key);
108100
}
109101
if (needsDispatch(key, bytesRead, contentLength, listener.getGranularityPercentage())) {
110-
handler.post(new Runnable() {
111-
@Override
112-
public void run() {
113-
listener.onProgress(key, bytesRead, contentLength);
114-
}
115-
});
102+
listener.onProgress(key, bytesRead, contentLength);
116103
}
117104
}
118105

0 commit comments

Comments
 (0)