1 Star 7 Fork 6

Danvie/architecture-components-samples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.circleci
.github
BasicRxJavaSample
BasicRxJavaSampleKotlin
BasicSample
GithubBrowserSample
LiveDataSample
NavigationAdvancedSample
NavigationBasicSample
PagingSample
PagingWithNetworkSample
app
benchmark
gradle/wrapper
lib
.gitignore
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle
versions.gradle
PersistenceContentProviderSample
PersistenceMigrationsSample
WorkManagerSample
gradle/wrapper
.gitignore
CONTRIBUTING.md
LICENSE
README.md
gradle-wrapper.properties
run_all_tests.sh
test_all_ftl.sh
update_versions.sh
versions.gradle
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

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

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/danvie/architecture-components-samples.git
git@gitee.com:danvie/architecture-components-samples.git
danvie
architecture-components-samples
architecture-components-samples
master

搜索帮助