Firebaseui-android: Sorting support

Created on 26 Mar 2016  Â·  5Comments  Â·  Source: firebase/FirebaseUI-Android

Passing a "sort by" argument to the ListVieworRecyclerView Firebaseadapters

Say I have a list with github repos and in real time of course people are *_starring *_them, it would be neat if we could sort by "most starred repos"

:+1:

Most helpful comment

You can sort your RecyclerView by passing a Query instead of a normal reference.

Query queryRef = mRef.orderByChild("points");
mAdapter = new FirebaseRecyclerAdapter<Eyesore, EyesoreViewHolder>(Eyesore.class,
            R.layout.eyesore_recycler_item, EyesoreViewHolder.class, queryRef) { ... }

All 5 comments

You can sort your RecyclerView by passing a Query instead of a normal reference.

Query queryRef = mRef.orderByChild("points");
mAdapter = new FirebaseRecyclerAdapter<Eyesore, EyesoreViewHolder>(Eyesore.class,
            R.layout.eyesore_recycler_item, EyesoreViewHolder.class, queryRef) { ... }

@raphaelseher true, forgot about it.

Thanks :+1:

I don't think it should be closed. We should have ability to pass some Comparator to sort as per our wish.
As FirebaseArray is an ArrayList, it should be possible. I might want to order ascending or descending.

The problem is that the re-ordering instructions from Firebase
(onChildChanged, onChildMoved) will not have any knowledge of the local
ordering, so we'll need to local translation layer. Keeping the library
simple and the code small is quite important. So while it is possible to
add this layer to FirebaseArray, I don't feel that would be worth the extra
code at the moment.

If we'd split FirebaseArray into a separate interface and implementation
class, this could be a new implementation class. But I haven't looked at
the impact of that yet.

On Wed, Sep 21, 2016 at 10:31 AM Chandra Sekhar Nayak <
[email protected]> wrote:

I don't think it should be closed. We should have ability to pass some
Comparator to sort as per our wish.
As FirebaseArray is an ArrayList, it should be possible. I might want to
order ascending or descending.

—
You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub
https://github.com/firebase/FirebaseUI-Android/issues/98#issuecomment-248684545,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA3w38viuW4xlWUIv_kOA80M8hv76pZrks5qsWoJgaJpZM4H5Fyb
.

I might have a case around sorting FirebaseRecyclerAdapter locally: http://stackoverflow.com/questions/40377794/android-client-side-sorting-with-firebaserecycleradapter

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iChintanSoni picture iChintanSoni  Â·  4Comments

joknu1 picture joknu1  Â·  4Comments

sbotev5 picture sbotev5  Â·  4Comments

ozican picture ozican  Â·  6Comments

dmikesell picture dmikesell  Â·  3Comments