I am using FirebaseIndexRecyclerAdapter as described in https://github.com/firebase/FirebaseUI-Android/tree/master/database . But there are many elements in my list, and I want to load a few elements first, and then lazy to load the rest when the user scrolls.
My first thought was that I could use mKeyRef.limitToLast(5) , but then updating this requires re-creating the adapter, right?
How do I get this lazy mechanic?
RecyclerView recycler = (RecyclerView) findViewById(R.id.messages_recycler); recycler.setHasFixedSize(true); recycler.setLayoutManager(new LinearLayoutManager(this)); mAdapter = new FirebaseIndexRecyclerAdapter<Chat, ChatHolder>( Chat.class, android.R.layout.two_line_list_item, ChatHolder.class, mIndexRef, mDataRef) { @Override public void populateViewHolder(ChatHolder chatMessageViewHolder, Chat chatMessage, int position) { chatMessageViewHolder.setName(chatMessage.getName()); chatMessageViewHolder.setText(chatMessage.getText()); } }; recycler.setAdapter(mAdapter);
source share