Run async differ on background thread

You keep telling developers to not run things in foreground threads,
so why-o-why Google isn't this the default?
pull/162/head
M66B 5 years ago
parent 88705707fd
commit 4adb2ae492

@ -145,6 +145,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.mail.Address;
import javax.mail.internet.InternetAddress;
@ -224,6 +226,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private DateFormat TF;
private DateFormat DTF;
private static final ExecutorService executor =
Executors.newFixedThreadPool(2, Helper.backgroundThreadFactory);
// https://github.com/newhouse/url-tracking-stripper
private static final List<String> PARANOID_QUERY = Collections.unmodifiableList(Arrays.asList(
"utm_source",
@ -3586,6 +3591,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
debug = prefs.getBoolean("debug", false);
AsyncDifferConfig<TupleMessageEx> config = new AsyncDifferConfig.Builder<>(DIFF_CALLBACK)
.setBackgroundThreadExecutor(executor)
.build();
this.differ = new AsyncPagedListDiffer<>(new AdapterListUpdateCallback(this), config);
this.differ.addPagedListListener(new AsyncPagedListDiffer.PagedListListener<TupleMessageEx>() {

Loading…
Cancel
Save