Skip to content

Basic android example where you can find how to use Paging Library.

Notifications You must be signed in to change notification settings

janirefdez/Paging3Example

Repository files navigation

Paging3Example

Kotlin Android Gradle

Basic android example where you can find how to use Paging library. This library helps you load and display pages of data from a larger dataset from local storage or over network.

Requirements

  • Android API 21 - 31
  • Gradle 7.2
  • Kotlin 1.6.10
  • Paging 3.1.1

Characteristics

  • MVVM
  • Clean Architecture
  • Dagger Hilt
  • LiveData
  • Coroutines
  • Retrofit
  • Http3 Logging
  • Room

Functionalities

  • Search GitHub repositories by name or description
  • List of repositories is displayed in descending order based on the number of stars
    • To be able to get the repositories we use request
GET https://api.github.com/search/repositories?sort=stars&q={searchValue}in:name,description&page={pageNumber}&per_page={pageSize}
  • Displaying the loading state in a footer.
    • When the list is loading, a progress spinner is displayed.
    • In case of an error, the error and a retry button is displayed.
image image
  • Include list separators
  • Offline support

Branches

To be able to understand how everything is implemented, the project is split in different branches:

  • master: Display list of items in a recycler view and automatically requests the correct page when the user has scrolled to the end of the list. Functionalities implemented in this branch:

    • Search GitHub repositories by name or description
    • List of repositories is displayed in descending order based on the number of stars
    • Displaying the loading state in a footer
  • list-separators: Improve list's readability by adding separators. In this app since the repositories are ordered by the number of stars descending, I included separators every 10k stars. Functionalities implemented in this branch:

    • Search GitHub repositories by name or description
    • List of repositories is displayed in descending order based on the number of stars
    • Displaying the loading state in a footer
    • Include list separators
  • room: Add offline support to our app by saving the data in a local database. That way, the database will be the source of truth for the app and it will always load data from there. Whenever it doesnt have any more data, it requests more from the network and then save it in the database. Because the database is the source of truth, the UI will be automatically updated when more data is saved. Functionalities implemented in this branch:

    • Search GitHub repositories by name or description
    • List of repositories is displayed in descending order based on the number of stars
    • Displaying the loading state in a footer
    • Offline support

Notes:

Demo

  • master:
DemoMasterBranch.mp4
  • list-separators:
DemoListSeparatorsBranch.mp4

About

Basic android example where you can find how to use Paging Library.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages