July 2018
Intermediate to advanced
266 pages
7h 11m
English
We want to be able to request articles as the user scrolls, so the first step is to connect the adapter with the articles to a listener that can fetch more articles when needed. To do this, we are first going to add an interface to the same file where the class ArticleAdapter resides:
interface ArticleLoader { suspend fun loadMore()}class ArticleAdapter: RecyclerView.Adapter<ArticleAdapter.ViewHolder>(){ ...}
This interface defines a suspending function that will load more articles if possible. Now we need to have the adapter receive an instance of that interface in the constructor, so that anyone using the adapter sends the proper listener. We will change the signature of the class to this:
class ...Read now
Unlock full access