How To Paginate Firebase From The Last Items To The First?
I am trying to get firebase pagination working but I want the newest items first and then the ones slightly older, I tried to work with this but cannot seem to get new values, keep
Solution 1:
Solution 1
While setting the values for projects you have to set one more additional property as timeStump.
projects.setTimeStump(System.currentTimeMillis());
then you can query like this
Query query=myRef.orderByChild("timeStump").limitToLast(50);
Solution 2
While setting projects you can set .priority variable of firebase as
item.setWithPriority(yourObject, 0 - Date.now());
and query it like
Query query=myRef.child('projects').startAt().limit(20);
Solution 2:
The offset had to be the same key used for orderByChild - that is why it did not work, so changed this endAt(offSet.get("first"))
value of the HashMap used to viewCount
Post a Comment for "How To Paginate Firebase From The Last Items To The First?"