Coder Social home page Coder Social logo

pagingwithnetwork's Introduction

Paging With Network Sample

This sample demonstrates how to use the Paging library with a backend API (in this case Reddit API).

There are 3 variations of the demo, which you can select in the MainActivity class.

After selecting an option, it starts the RedditActivity which is the activity that shows the list of posts in a given subreddit.

Paging With Database And Network

This sample, implemented in the DbRedditPostRepository class, demonstrates how to set up a Repository that will use the local database to page in data for the UI and also back-fill the database from the network as the user reaches to the end of the data in the database.

It uses Room to create the DataSource.Factory (dao) and the Paging Boundary Callback API to get notified when the Paging library consumes the available local data (boundary callback implementation)

This usually provides the best user experience as the cached content is always available on the device and the user will still have a good experience even if the network is slow / unavailable.

Paging Using Item Keys

This sample, implemented in the InMemoryByItemRepository class, demonstrates how to set up a Repository that will directly page in from the network and will use the key from the previous item to find the request parameters for the next page.

ItemKeyedSubredditDataSource: The data source that uses the key in items (name in Reddit API) to find the next page. It extends from the ItemKeyedDataSource class in the Paging Library.

Paging Using Next Tokens From The Previous Query

This sample, implemented in the InMemoryByPageKeyRepository class, demonstrates how to utilize the before and after keys in the response to discover the next page. (This is the intended use of the Reddit API but this sample still provides ItemKeyedSubredditDataSource to serve as an example if the backend does not provide before/after links)

PageKeyedSubredditDataSource: The data source that uses the after and before fields in the API request response. It extends from the PageKeyedDataSource class in the Paging Library.

Libraries

pagingwithnetwork's People

Watchers

James Cloos avatar Neo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.