How do I add items to the top of a RecyclerView
using 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 start. Remember that this adapter is different from the Android standard.
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:
Searching, I saw that this adapter
gets the information exactly as it is in firebase
, including the order, so I would have to insert already in the right order in firebase
, but how to do that?