davideas / FlexibleAdapter

Fast and versatile Adapter for RecyclerView which regroups several features into one library to considerably improve the user experience :-)
Apache License 2.0
3.55k stars 553 forks source link

How I can hide progressbar(onLoadMoreComplete)? #202

Closed ulx closed 8 years ago

ulx commented 8 years ago

2) For questions / new feature / improvement

davideas commented 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.

ulx commented 8 years ago

Sorry, I use b8 I call onLoadMoreComplete(null) Must I remove ProgressItem?

davideas commented 8 years ago

Probably is a second effect of the issue #184, can you try to use the Snapshot version? (Just created a new Snapshot).

ulx commented 8 years ago

OK, I will be try tomorrow

ulx commented 8 years ago

compile 'eu.davidea:flexible-adapter:5.0.0-SNAPSHOT' It is not helped me.

DarklyCoder commented 8 years ago

I encountered the same problem!

davideas commented 8 years ago

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.

ulx commented 8 years ago

@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);
    }
davideas commented 8 years ago

@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).

ulx commented 8 years ago

Sorry, It was my wrong. Duplicate call update on

davideas commented 7 years ago

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.