Use background executor for paged message list

pull/156/head
M66B 6 years ago
parent b4680dcab9
commit 9d56de35ef

@ -93,6 +93,8 @@ import androidx.paging.PagedList;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.recyclerview.selection.ItemDetailsLookup; import androidx.recyclerview.selection.ItemDetailsLookup;
import androidx.recyclerview.selection.SelectionTracker; import androidx.recyclerview.selection.SelectionTracker;
import androidx.recyclerview.widget.AdapterListUpdateCallback;
import androidx.recyclerview.widget.AsyncDifferConfig;
import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -118,6 +120,8 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.mail.Address; import javax.mail.Address;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
@ -181,6 +185,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private DateFormat TF; private DateFormat TF;
private DateFormat DTF = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.LONG, SimpleDateFormat.LONG); private DateFormat DTF = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.LONG, SimpleDateFormat.LONG);
private static ExecutorService executor = Executors.newCachedThreadPool(Helper.backgroundThreadFactory);
private static final List<String> PARANOID_QUERY = Collections.unmodifiableList(Arrays.asList( private static final List<String> PARANOID_QUERY = Collections.unmodifiableList(Arrays.asList(
"utm_source", "utm_source",
"utm_medium", "utm_medium",
@ -3447,7 +3453,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.authentication = prefs.getBoolean("authentication", false); this.authentication = prefs.getBoolean("authentication", false);
this.debug = prefs.getBoolean("debug", false); this.debug = prefs.getBoolean("debug", false);
this.differ = new AsyncPagedListDiffer<>(this, DIFF_CALLBACK); 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>() { this.differ.addPagedListListener(new AsyncPagedListDiffer.PagedListListener<TupleMessageEx>() {
@Override @Override
public void onCurrentListChanged(@Nullable PagedList<TupleMessageEx> previousList, @Nullable PagedList<TupleMessageEx> currentList) { public void onCurrentListChanged(@Nullable PagedList<TupleMessageEx> previousList, @Nullable PagedList<TupleMessageEx> currentList) {

Loading…
Cancel
Save