0
How do I add items to the top of a RecyclerView
using the FirebaseRecyclerAdapter
?
By default, whenever I add an item, it goes to the bottom of the Recyclerview list, and I want it to go to the top. Remembering that this Adapter is different from the standard of Android.
noteAdapter = new FirebaseRecyclerAdapter<Note, NoteHolder>(Note.class, R.layout.note_item, NoteHolder.class, dbRef) {
@Override
protected void populateViewHolder(NoteHolder viewHolder, final Note model, final int position) {
viewHolder.setTitle(model.getTitle());
viewHolder.setContent(model.getContent());
viewHolder.setColor(model.getColorBg());
model.setId(getRef(position).getKey());
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent it = new Intent(v.getContext(), NoteDetailActivity.class);
it.putExtra(Note.NOTE_PARCE, model);
startActivity(it);
}
});
}
};
notesRecyclerView.setLayoutManager(layoutManager);
notesRecyclerView.setAdapter(noteAdapter);
UPDATE:
Researching on, I saw that this adapter
picks up the information exactly as it is on firebase
, including the order, so I would have to insert already in the right order in the firebase
, but how to do this?
I’m not using list, this Adapter already does everything, it returns the object I want, but I don’t keep it in a list, and you don’t use list on it, that’s the problem, it does everything... But I need to use it for recyclerview
– felipe.rce
@Felipe.rce What is this dbRef then?
– viana
Databasereference variable, it’s not a list, it’s firebase stuff... I even tried to use list to manipulate the order, but not da, firebase puts that same, only solution is to insert in firebase... Insert in the right order, but I’ve researched a lot and I haven’t seen anything about
– felipe.rce