vinaysshenoy / mugen

Microlibrary for implementing infinite scroll on Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't get it work with RecyclerView

pavlospt opened this issue · comments

I am trying to use it with a recyclerview but it doesnt seem to wanna work. below is my code:

mBaseAttacher = Mugen.with(mMessagesRecycler, new MugenCallbacks() {
@OverRide
public void onLoadMore() {
Log.e(TAG, "Triggered load more");
loadSomeMoreMessages();
}

        @Override
        public boolean isLoading() {
            return isLoading;
        }

        @Override
        public boolean hasLoadedAllItems() {
            return hasLoadedAllItems;
        }
    });

    mBaseAttacher.setLoadMoreOffset(5);
    mBaseAttacher.setLoadMoreEnabled(true);
    mBaseAttacher.start(); ``

mBaseAttacher is a RecyclerviewAttacher

Have you loaded the first set of items? The first set must be loaded manually. After the list gets enough items and becomes scrollable, then it starts working.

So i have to load items and then instantiate the attacher?

You can instantiate the attacher at any time. The load more trigger is when the list starts scrolling and reaches towards the end, so unless there are enough items already in the list, the triggers will not get called.

I'll update the documentation to make it more clear.

The list has enough items to be scrollable but yet it doesn't seem to call "loadMore()"

Sorry for the annoyance, it was just a logical error. Thank you for your work!

Can you check the value of isLoading? It should be false intially.

@vinaysshenoy I was setting hasLoadedAllItems to true without checking that the server has no more data to feed, so it wasn't triggering the "loadMore()".

Oh, all right. Sounds good. Please report any issues if you come across any, and we'll fix them up asap.

Hope you like mugen. :-)

@vinaysshenoy Yes of course, thanks again for your work and your time!