We are not using any MVC, MVP, or MVVM paradigms because that is not the purpose of this book, so our Activity
class will contain all the logic we need to create and show our list of users.
We will set up SwipeRefreshLayout
and RecyclerView
in our onCreate()
method; we have a refreshList()
method to handle the fetching and showing of our list of users and showRefreshing()
to manage the ProgressBar
and RecyclerView
visibility.
Our refreshList()
function looks like this:
private void refreshList() { showRefresh(true); mSeApiManager.getMostPopularSOusers(10) .subscribe(users -> { showRefresh(false); mAdapter.updateUsers(users); }, error -> { App.L.error(error.toString()); showRefresh(false); }); }
We show ProgressBar
, and observe the list of users from the StackExchange API manager. The moment the list comes in, we show it and update the...