1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 18:27:43 +00:00

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?
This commit is contained in:
M66B 2019-10-10 11:33:55 +02:00
parent 88705707fd
commit 4adb2ae492

View file

@ -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>() {