Managing present and loading states
The Paging library offers the loading state information to users through its load state object, which can have different forms based on its current loading state. For example, if you have an active load, then the state will be LoadState.Loading
.
If you have an error state, then the state will be a LoadState.Error
; and finally, there might be no active load operation, and this state is called the LoadState.NotLoading.
In this recipe, we will explore the different states and get to understand them; the example demonstrated here can also be found at the following link: https://developer.android.com/topic/libraries/architecture/paging/load-state. In this example, we assume your project uses legacy code, which utilizes XML for the view system.
Getting ready
To follow along with this recipe, you need to have completed the code in the previous recipe. You can also skip this if it is not required in your project.
How to do it…
We will...