Fixed page size

pull/145/head
M66B 6 years ago
parent 1647e3e652
commit 7fd089b0af

@ -88,8 +88,8 @@ public class FragmentMessages extends FragmentEx {
private ExecutorService executor = Executors.newCachedThreadPool(Helper.backgroundThreadFactory); private ExecutorService executor = Executors.newCachedThreadPool(Helper.backgroundThreadFactory);
private static final int MESSAGES_PAGE_SIZE = 50; private static final int LOCAL_PAGE_SIZE = 50;
private static final int SEARCH_PAGE_SIZE = 10; private static final int REMOTE_PAGE_SIZE = 10;
private static final int UNDO_TIMEOUT = 5000; // milliseconds private static final int UNDO_TIMEOUT = 5000; // milliseconds
@Override @Override
@ -661,13 +661,13 @@ public class FragmentMessages extends FragmentEx {
switch (viewType) { switch (viewType) {
case UNIFIED: 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; break;
case FOLDER: case FOLDER:
if (searchCallback == null) if (searchCallback == null)
searchCallback = new BoundaryCallbackMessages( searchCallback = new BoundaryCallbackMessages(
getContext(), FragmentMessages.this, getContext(), FragmentMessages.this,
folder, null, MESSAGES_PAGE_SIZE, folder, null, REMOTE_PAGE_SIZE,
new BoundaryCallbackMessages.IBoundaryCallbackMessages() { new BoundaryCallbackMessages.IBoundaryCallbackMessages() {
@Override @Override
public void onLoading() { 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<Integer, TupleMessageEx> builder = new LivePagedListBuilder<>( LivePagedListBuilder<Integer, TupleMessageEx> builder = new LivePagedListBuilder<>(
db.message().pagedFolder(folder, sort, false, debug), config); db.message().pagedFolder(folder, sort, false, debug), LOCAL_PAGE_SIZE);
builder.setBoundaryCallback(searchCallback); builder.setBoundaryCallback(searchCallback);
messages = builder.build(); messages = builder.build();
break; break;
case THREAD: 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; break;
} }
} else { } else {
if (searchCallback == null) if (searchCallback == null)
searchCallback = new BoundaryCallbackMessages( searchCallback = new BoundaryCallbackMessages(
getContext(), FragmentMessages.this, getContext(), FragmentMessages.this,
folder, search, SEARCH_PAGE_SIZE, folder, search, REMOTE_PAGE_SIZE,
new BoundaryCallbackMessages.IBoundaryCallbackMessages() { new BoundaryCallbackMessages.IBoundaryCallbackMessages() {
@Override @Override
public void onLoading() { 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<Integer, TupleMessageEx> builder = new LivePagedListBuilder<>( LivePagedListBuilder<Integer, TupleMessageEx> builder = new LivePagedListBuilder<>(
db.message().pagedFolder(folder, "time", true, false), config); db.message().pagedFolder(folder, "time", true, false), LOCAL_PAGE_SIZE);
builder.setBoundaryCallback(searchCallback); builder.setBoundaryCallback(searchCallback);
messages = builder.build(); messages = builder.build();
} }

Loading…
Cancel
Save