Closed ulx closed 8 years ago
@ulx, onLoadMoreComplete(newItems)
should work, unless you have set null the progress item in the meantime.
Did you read the wiki page dedicated for the loading more and the javaDoc of this method?
Also, which version are you using? b8 or Snapshot (check the latest modification in issue 39)?
It's supposed to be an automatic loading: if at start up you have not filled fully the screen with items, the the chain of methods for loading more will be called and progress item displayed if previously set, until you receive no more items by calling onLoadMoreComplete(null)
inside the listener, it removes the item from the list. Check also the demo app, it works when no more load.
Sorry, I use b8 I call onLoadMoreComplete(null) Must I remove ProgressItem?
Probably is a second effect of the issue #184, can you try to use the Snapshot version? (Just created a new Snapshot).
OK, I will be try tomorrow
compile 'eu.davidea:flexible-adapter:5.0.0-SNAPSHOT' It is not helped me.
I encountered the same problem!
Dears, would you try to share some code and logs? because in the demo app the progressItem
is automatically removed from the list when no more load (new list empty or null). So, I would like to understand if there's a real problem or just a wrong configuration.
@davideas , you right FragmentEndlessScrolling is work normal. I use ProgressItem.java from sample. Is it my wrong?
private void initListView() {
rvOperationsAdapter = new CommonAdapter(null);
rvOperationsAdapter.setRemoveOrphanHeaders(false)
.setNotifyChangeOfUnfilteredItems(true);
rvOperations.setLayoutManager(createNewLinearLayoutManager());
rvOperations.setAdapter(rvOperationsAdapter);
rvOperations.setHasFixedSize(true);
rvOperations.setItemAnimator(new DefaultItemAnimator());
rvOperations.addItemDecoration(new DividerItemDecoration(getContext(), 0, 0));
rvOperationsAdapter
.setUnlinkAllItemsOnRemoveHeaders(true)
.setDisplayHeadersAtStartUp(true)
.enableStickyHeaders()
.setDisplayHeadersAtStartUp(true)
.showAllHeaders();
rvOperationsAdapter.addUserLearnedSelection(filterItem, true);
rvOperationsAdapter.setEndlessScrollListener(new LoadMoreListner(), progressItem);
rvOperationsAdapter.setEndlessScrollThreshold(2);
}
private List<AbstractFlexibleItem> createItems(List<HistoryOperation> listOperations) {
final List<AbstractFlexibleItem> newItems = new ArrayList<>(listOperations.size());
String prev = "";
if (!rvOperationsAdapter.getHeaderItems().isEmpty()) {
prev = ((HeaderItem) rvOperationsAdapter.getHeaderItems().get(rvOperationsAdapter.getHeaderItems().size() - 1)).getTitle();
}
HeaderItem header = null;
for (HistoryOperation item : listOperations) {
header = new HeaderItem(item.id + "");
header.setTitle(DateUtils.parseDate(item.date));
if (prev.equals(header.getTitle())) {
header.setHidden(false);
}
prev = header.getTitle();
HistoryOperationItemView historyOperationItemView = new HistoryOperationItemView(item, header);
historyOperationItemView.setOnclickItem(operation -> showDetailsObservable.onNext(operation));
newItems.add(historyOperationItemView);
}
return newItems;
}
private void addItem(List<HistoryOperation> listOperations) {
if ((listOperations == null) || listOperations.isEmpty()) {
rvOperationsAdapter.onLoadMoreComplete(null);
return;
}
rvOperationsAdapter.onLoadMoreComplete(createItems(listOperations));
}
private void setMoreOperations(List<HistoryOperation> listOperations) {
addItem(listOperations);
}
@ulx, allright, make more tests then decide if you can close this issue.
I don't how you mean the loading more, but for me, in the implementation of this listener there should be only the call for a Rest(?) API (for instance), for a remote call with a gateway service class. When the remote call receives a response, in another user defined method, then, in this third method, we update the local database and the user interface by notifying the adapter by calling Adapter.onLoadMoreComplete(newItems)
.
Sorry, It was my wrong. Duplicate call update on
Please be aware that, Endless Scrolling is going to be changed very soon. In order to support the new features and a better logic, the behaviors and callbacks methods will be refactored.
Please check issue #233 for the latest developments.
2) For questions / new feature / improvement