Source:
<code>private void setUpAdapter() { PagedList.Config config = new PagedList.Config.Builder() .setEnablePlaceholders(false) .setPrefetchDistance(5) .setPageSize(30) .build(); <START> FirebasePagingOptions<Post> options = new FirebasePagingOptions.Builder<Post>() <END> .setLifecycleOwner(this) .setQuery(mQuery, config, Post.class) .build(); FirebaseRecyclerPagingAdapter<Post, PostViewHolder> mAdapter = new FirebaseRecyclerPagingAdapter<Post, PostViewHolder>(options) { @NonNull @Override public PostViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.item_post, parent, false); return new PostViewHolder(view); } @Override protected void onBindViewHolder(@NonNull PostViewHolder holder, int position, @NonNull String key, @NonNull Post model) { holder.bind(model); } }; mRecycler.setLayoutManager(new LinearLayoutManager(this)); mRecycler.setAdapter(mAdapter); mAdapter.setStateChangedListener(new StateChangedListener() { @Override public void onInitLoading() { mProgressBar.setVisibility(View.VISIBLE); } @Override public void onLoading() { mProgressBar.setVisibility(View.VISIBLE); } @Override public void onLoaded() { mProgressBar.setVisibility(View.GONE); } @Override public void onFinished() { mProgressBar.setVisibility(View.GONE); Toast.makeText(getApplicationContext(), getString(R.string.paging_finished_message), Toast.LENGTH_SHORT).show(); } @Override public void onError(DatabaseError databaseError) { mProgressBar.setVisibility(View.GONE); Log.e(TAG, databaseError.getMessage()); } }); }</code><technical_language>Firestore version of this is called FirestorePagingOptions I this called DatabasePagingOptions. "Firebase" is general applies both</technical_language>

Target:
private void setUpAdapter() { PagedList.Config config = new PagedList.Config.Builder() .setEnablePlaceholders(false) .setPrefetchDistance(5) .setPageSize(30) .build(); DatabasePagingOptions<Post> options = new DatabasePagingOptions.Builder<Post>() .setLifecycleOwner(this) .setQuery(mQuery, config, Post.class) .build(); final FirebaseRecyclerPagingAdapter<Post, PostViewHolder> mAdapter = new FirebaseRecyclerPagingAdapter<Post, PostViewHolder>(options) { @NonNull @Override public PostViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.item_post, parent, false); return new PostViewHolder(view); } @Override protected void onBindViewHolder(@NonNull PostViewHolder holder, int position, @NonNull Post model) { holder.bind(model); } @Override protected void onLoadingStateChanged(@NonNull LoadingState state) { switch (state) { case LOADING_INITIAL: case LOADING_MORE: mSwipeRefreshLayout.setRefreshing(true); break; case LOADED: mSwipeRefreshLayout.setRefreshing(false); break; case FINISHED: mSwipeRefreshLayout.setRefreshing(false); Toast.makeText(getApplicationContext(), getString(R.string.paging_finished_message), Toast.LENGTH_SHORT).show(); break; case ERROR: retry(); break; } } @Override protected void onError(DatabaseError databaseError) { mSwipeRefreshLayout.setRefreshing(false); Log.e(TAG, databaseError.getMessage()); } }; mRecycler.setLayoutManager(new LinearLayoutManager(this)); mRecycler.setAdapter(mAdapter); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mAdapter.refresh(); } }); }