Android Jetpack: Manage infinite lists with RecyclerView and Paging (Google I/O '18)

Android Developers · 80K views · 2018 · 32:41

Open on YouTube

Software architecture & designSoftware (other)talkdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering or asking about paginated RecyclerView lists, PagedListAdapter, DataSources and BoundaryCallback with the Android Paging library.

Recommended by 5 people across 5 different months, 2018 to 2019.

What it is

A Google I/O 2018 session by Yigit Boyar and Chris Craik introducing the Paging Library in Android Architecture Components. It walks through local (Room) and remote (Retrofit) data examples, explains the design, and shows how it fits with other architecture components for infinite RecyclerView lists.

What people said

Recommends TapanHP · 2018-05 · Stack Overflow · on “What exactly is Android Jetpack?”

Basically it is just set of useful things combined and sorted under 4 categories Foundation Architecture Behavior UI Some of the core things like AppCompat library, Architecture components, Fragments, Animation and transitions and many more were added now in relative categories and these 5 things were newly added. Android Ktx [LINK] The purpose of Android KTX is to make Android development with Kotlin more concise, pleasant, and idiomatic by leveraging Kotlin language features such as extension functions/properties, lambdas, named parameters, and parameter default values Navigation [LINK] The Navigation Architecture Component simplifies the implementation of navigation in an Android app.This

Recommends Ioane Sharvadze · 2018-07 · Stack Overflow · on “CursorAdapter: newView and bindView never called”

I see problem in your onCreateView in your fragment. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.snapshots_list, container, false); final ListView snapshotsListView = (ListView) view.findViewById(R.id.snapshots_list); final SnapshotSelectAdapter adapter = new SnapshotSelectAdapter(getActivity(), R.layout.snapshots_item, mCursor, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); snapshotsListView.setAdapter(adapter); // check for the adapter to be set properly - OK Log.d(TAG, "snapshots list view: " + snapshotsListView.getAdapter()); return view } You should return view from this method,

Recommends Soon Santos · 2018-09 · Stack Overflow · on “How to load data into reclyerview while downloading them from post async http request”

Maybe you want to do pagination. It is the same thing that happens in social media feed, the content will download as you scroll down. For example, when you enter in the youtube app there is some video in your feed and then when you scroll down, it starts loading and then some new videos appear, this is called Pagination. This is a complex approach but you can do it by reading the following articles. Paging Android Guide [LINK] , Video about Paging [this video] . After reading these articles you can follow this tutorial [LINK] , and here [LINK] is the source code of this tutorial.

Recommends Daniel Gomez Rico · 2019-05 · Stack Overflow · on “Initial placeholder with Paging Architecture Components”

There's a method from where you should pass the data set size, I think that it is what you are missing. public abstract static class LoadInitialCallback<Key, Value> { /** * Called to pass initial load state from a DataSource. * <p> * Call this method from your DataSource's {@code loadInitial} function to return data, * and inform how many placeholders should be shown before and after. If counting is cheap * to compute (for example, if a network load returns the information regardless), it's * recommended to pass data back through this method. * <p> * It is always valid to pass a different amount of data than what is requested. Pass an * empty list if there is no more data to load. * * @param

Recommends Tuan Dao · 2019-11 · Stack Overflow · on “UI lags and is choppy when using Glide to load images in a RecyclerView”

Try to use paging library combined with recyclerview link reference: Paging Library for Android With Kotlin: Creating Infinite Lists [LINK] Android Jetpack: manage infinite lists with RecyclerView and Paging (Google I/O '18) [this video]

Cites Santanu Sur · 2018-05 · Stack Overflow · on “FastScrolling recyclerView with PagedListAdapter<Object, RecyclerView.ViewHolder> crashing when scrolled fast Why?”

My dao @Dao public abstract class UserDao { @Query("SELECT * FROM Users GROUP BY locality,fullName") public abstract PositionalDataSource.Factory<Integer, User> getUserLocalityGrouped(); } As suggested in Google I/O video [this video] i used PositionalDataSource.Factory<Integer, User> for fast scrolling recyclerView . But getItem(position) is null in PagedListAdapter when the user uses the fast scroll. Why ? NOTE :- If the user doesnt use the fast scroll mechanism and uses the general scroll of recyclerView the app doesnt crash.

Cites Saman Sattari · 2019-01 · Stack Overflow · on “Android Paging Library - Data + Network with multiple sorting types”

I recently saw that google has a great library for paginating data. In this Google IO: Android Jetpack: manage infinite lists with RecyclerView and Paging (Google I/O '18) [this video] They explained how to make Data + Network DataSource and grab data from database as Single Source of Truth and when the database is out of data it request for more data from the network with BoundaryCallback . So assume that I have a list of Movies on the server. And client (Android user) can sort them by popularity, title, date_release and ... So in the first time if the user sort movies by titles everything will work great because there is no data in database and data will be requested from the server to sort the