From 7fd089b0af2d085be83242234891a87e1a44b487 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 21 Sep 2018 13:36:48 +0000 Subject: [PATCH] Fixed page size --- .../eu/faircode/email/FragmentMessages.java | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index e6e811cf08..dfc9390ff0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -88,8 +88,8 @@ public class FragmentMessages extends FragmentEx { private ExecutorService executor = Executors.newCachedThreadPool(Helper.backgroundThreadFactory); - private static final int MESSAGES_PAGE_SIZE = 50; - private static final int SEARCH_PAGE_SIZE = 10; + private static final int LOCAL_PAGE_SIZE = 50; + private static final int REMOTE_PAGE_SIZE = 10; private static final int UNDO_TIMEOUT = 5000; // milliseconds @Override @@ -661,13 +661,13 @@ public class FragmentMessages extends FragmentEx { switch (viewType) { case UNIFIED: - messages = new LivePagedListBuilder<>(db.message().pagedUnifiedInbox(sort, debug), MESSAGES_PAGE_SIZE).build(); + messages = new LivePagedListBuilder<>(db.message().pagedUnifiedInbox(sort, debug), LOCAL_PAGE_SIZE).build(); break; case FOLDER: if (searchCallback == null) searchCallback = new BoundaryCallbackMessages( getContext(), FragmentMessages.this, - folder, null, MESSAGES_PAGE_SIZE, + folder, null, REMOTE_PAGE_SIZE, new BoundaryCallbackMessages.IBoundaryCallbackMessages() { @Override public void onLoading() { @@ -686,25 +686,21 @@ public class FragmentMessages extends FragmentEx { } }); - PagedList.Config config = new PagedList.Config.Builder() - .setPageSize(MESSAGES_PAGE_SIZE) - .setPrefetchDistance(MESSAGES_PAGE_SIZE) - .build(); LivePagedListBuilder builder = new LivePagedListBuilder<>( - db.message().pagedFolder(folder, sort, false, debug), config); + db.message().pagedFolder(folder, sort, false, debug), LOCAL_PAGE_SIZE); builder.setBoundaryCallback(searchCallback); messages = builder.build(); break; case THREAD: - messages = new LivePagedListBuilder<>(db.message().pagedThread(thread, sort, debug), MESSAGES_PAGE_SIZE).build(); + messages = new LivePagedListBuilder<>(db.message().pagedThread(thread, sort, debug), LOCAL_PAGE_SIZE).build(); break; } } else { if (searchCallback == null) searchCallback = new BoundaryCallbackMessages( getContext(), FragmentMessages.this, - folder, search, SEARCH_PAGE_SIZE, + folder, search, REMOTE_PAGE_SIZE, new BoundaryCallbackMessages.IBoundaryCallbackMessages() { @Override public void onLoading() { @@ -726,12 +722,8 @@ public class FragmentMessages extends FragmentEx { } }); - PagedList.Config config = new PagedList.Config.Builder() - .setPageSize(SEARCH_PAGE_SIZE) - .setPrefetchDistance(SEARCH_PAGE_SIZE) - .build(); LivePagedListBuilder builder = new LivePagedListBuilder<>( - db.message().pagedFolder(folder, "time", true, false), config); + db.message().pagedFolder(folder, "time", true, false), LOCAL_PAGE_SIZE); builder.setBoundaryCallback(searchCallback); messages = builder.build(); }