/Android-Paging-Library-Room-Java

Android Paging Library & Room Java Example

Primary LanguageJava

Android-Paging-Library-Room-Java

This is a conversion of kotlin project from Paging Codelab to java.

Project Overview

The app allows you to search GitHub for repositories whose name or description contains a specific word. The list of repositories is displayed, in descending order based on the number of stars, then by the name. The database is the source of truth for data that is displayed by the UI, and it's backed by network requests.

The list of repositories, by name, is retrieved via a LiveData object in RepoDao.reposByName. Whenever new data from the network is inserted into the database, the LiveData will emit again with the entire result of the query.

The app follows the architecture recommended in the "Guide to App Architecture", using Room as local data storage. Here's what you will find in each package:

  • api - contains Github API calls, using Retrofit
  • db - database cache for network data
  • data - contains the repository class, responsible for triggering API requests and saving the response in the database
  • ui - contains classes related to displaying an Activity with a RecyclerView
  • model - contains the Repo data model, which is also a table in the Room database; and RepoSearchResult, a class that is used by the UI to observe both search results data and network errors