Android - Client-side Sorting With Firebaserecycleradapter
I'm building an application with Firebase on Android. The scenario for my application is as follows. Look at the following screen. As you can see, in the above screen, I'm display
Solution 1:
Originally, I was thinking there would be some additional Comparators in the works, but it turns out Frank's answer led me to the right direction.
Per Frank's comment above, these two tricks worked for me:
Override the getItem method inside the FirebaseRecyclerAdapter as follows:
@Overridepublic User getItem(int position) {
returnsuper.getItem(getItemCount() - 1 - position);
}
But I finally went with setting the LinearLayoutManager as follows:
LinearLayoutManagerlinearLayoutManager=newLinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
linearLayoutManager.setStackFromEnd(true);
linearLayoutManager.setReverseLayout(true);
mRecyclerView.setLayoutManager(linearLayoutManager);
Although this solution does solve my problem, hopefully there will be more enhancements coming to the Firebase library for data manipulation.
Post a Comment for "Android - Client-side Sorting With Firebaserecycleradapter"