Android RecyclerView with Paging Library | Data Binding | Live Data | Retrofit

preview_player
Показать описание
The Paging Library helps you load and display small chunks of data at a time. Loading partial data on-demand reduces the usage of network bandwidth and system resources.

Advantages of Paging Library

1. The user gets content faster.

2. The app only needs to download one or two pages to show.

3. The user gets content faster.

4. Uses far less memory.

5. Uses less data as it doesn’t need the full dataset.

6. Even during data updates and refreshes, the app responds quickly.

7. You can observe and update data more easily.

8. You can use placeholders to indicate if new content is being downloaded.





References for the tutorial :

Complete source code can be found in below link:


Thank you!
Рекомендации по теме
Комментарии
Автор

you are the only clear pagging library with kotlin on youtube soo far consider audio recording also

zaloaustine
Автор

I have one more question. I want different fragments to initiate a different function from the APIService file. I thought the simplest way to do this would be to place a string as parameter inside the UserViewModel class like this



{

val itemViewModel = a different function")::class.java)

}



And then using a Kotlin when statement in the UserDataSource file to change the value of call to a different function based on what the string sais.



However, when i do the code above that i placed in brackets my app crashes. Would you be able to show me the simplest way of being able to change which function is used based on the fragment.

jevonmcpherson
Автор

Hy Sir, how can we implement paging when we fetching our data from MySQL

lucasianii
Автор

Im trying to figure out how to do this in a fragment, I'm new to Kotlin so my understanding of the structure of the programming language is little.

What I've tried is in my fragment class inside of the

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {}

i have placed this bit of code `adapter = UserAdapter()`

I'm guessing i have to tell the onCreateView() function which adapter class to use for the adapting however, this returns an empty fragment.

How do i put your work inside of a fragment?

jevonmcpherson