Firebase RecyclerView infinite scroll
Asked Answered
W

1

6

I'm looking for a way to implement infinite scrolling in my Firebase app.

I'm retrieving my data the following way :

I have a list of keys (items a user created, items a user liked and stuff like this) that I am sending to an adapter which gets the data like this :

 public void onBindViewHolder(final BaseViewHolder viewHolder, final int position) {

    DatabaseReference ref = getAllItemsRef().child(itemIDs.get(position));

    ValueEventListener itemListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Item item = dataSnapshot.getValue(Item.class);
            viewHolder.bindItem(item);
        }

        @Override
        public void onCancelled(DatabaseError firebaseError) {
        }
    };
    ref.addValueEventListener(itemListener);

}

I would like to add infinite scrolling to gain performance but I have no idea how I should do that with Firebase.

I've seen that FirebaseUI would like to implement it but haven't done it yet.

Wonderland answered 21/9, 2016 at 16:43 Comment(1)
Possible duplicate of Infinite scroll with AngularJs and FirebaseStaub
P
1

It is very simply achievable with a combination of startAt, limitToLast and orderByKey/orderByChild

Pelops answered 18/3, 2017 at 14:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.