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

fix(android): remove explicit use of UI thread #698

Merged
merged 4 commits into from
Jul 17, 2020
Merged
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
@@ -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