Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit a73e2b9

Browse files
authored
Merge pull request #885 from dennis-sheil/readme-update
Update PagingWithNetworkSample README
2 parents 1816dea + 36c925d commit a73e2b9

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

PagingWithNetworkSample/README.md

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Paging With Network Sample
22

33
This sample demonstrates how to use the Paging library with a backend API (in this
4-
case [Reddit API][8]).
4+
case [Reddit API][7]).
55

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

@@ -13,9 +13,8 @@ This sample, implemented in the [DbRedditPostRepository][1] class, demonstrates
1313
a Repository that will use the local database to page in data for the UI and also back-fill
1414
the database from the network as the user reaches to the end of the data in the database.
1515

16-
It uses `Room` to create the `DataSource.Factory` ([dao][3]) and the Paging Boundary Callback
17-
API to get notified when the Paging library consumes the available local data ([boundary callback
18-
implementation][4])
16+
It uses `Room` to create the `PagingSource` ([dao][3]). The `Pager` creates a stream of
17+
data from the PagingSource to the UI, and more data is paged in as it is consumed.
1918

2019
This usually provides the best user experience as the cached content is always available
2120
on the device and the user will still have a good experience even if the network is slow /
@@ -26,18 +25,18 @@ This sample, implemented in the [InMemoryByItemRepository][2] class, demonstrate
2625
set up a Repository that will directly page in from the network and will use the `key` from
2726
the previous item to find the request parameters for the next page.
2827

29-
[ItemKeyedSubredditPagingSource][5]: The data source that uses the `key` in items
28+
[ItemKeyedSubredditPagingSource][4]: The data source that uses the `key` in items
3029
(`name` in Reddit API) to find the next page. It extends from the `PagingSource` class
3130
in the Paging Library.
3231

3332
## Paging Using Next Tokens From The Previous Query
34-
This sample, implemented in the [InMemoryByPageKeyRepository][6] class, demonstrates how to
33+
This sample, implemented in the [InMemoryByPageKeyRepository][5] class, demonstrates how to
3534
utilize the `before` and `after` keys in the response to discover the next page. (This is
3635
the intended use of the Reddit API but this sample still provides
37-
[ItemKeyedSubredditPagingSource][5] to serve as an example if the backend does not provide
36+
[ItemKeyedSubredditPagingSource][4] to serve as an example if the backend does not provide
3837
before/after links)
3938

40-
[PageKeyedSubredditPagingSource][7]: The data source that uses the `after` and `before` fields
39+
[PageKeyedSubredditPagingSource][6]: The data source that uses the `after` and `before` fields
4140
in the API request response. It extends from the `PagingSource` class in the Paging Library.
4241

4342

@@ -53,11 +52,10 @@ in the API request response. It extends from the `PagingSource` class in the Pag
5352
[1]: app/src/main/java/com/android/example/paging/pagingwithnetwork/reddit/repository/inDb/DbRedditPostRepository.kt
5453
[2]: app/src/main/java/com/android/example/paging/pagingwithnetwork/reddit/repository/inMemory/byItem/InMemoryByItemRepository.kt
5554
[3]: app/src/main/java/com/android/example/paging/pagingwithnetwork/reddit/db/RedditPostDao.kt
56-
[4]: app/src/main/java/com/android/example/paging/pagingwithnetwork/reddit/repository/inDb/SubredditBoundaryCallback.kt
57-
[5]: app/src/main/java/com/android/example/paging/pagingwithnetwork/reddit/repository/inMemory/byItem/ItemKeyedSubredditPagingSource.kt
58-
[6]: app/src/main/java/com/android/example/paging/pagingwithnetwork/reddit/repository/inMemory/byPage/InMemoryByPageKeyRepository.kt
59-
[7]: app/src/main/java/com/android/example/paging/pagingwithnetwork/reddit/repository/inMemory/byPage/PageKeyedSubredditPagingSource.kt
60-
[8]: https://www.reddit.com/dev/api/#listings
55+
[4]: app/src/main/java/com/android/example/paging/pagingwithnetwork/reddit/repository/inMemory/byItem/ItemKeyedSubredditPagingSource.kt
56+
[5]: app/src/main/java/com/android/example/paging/pagingwithnetwork/reddit/repository/inMemory/byPage/InMemoryByPageKeyRepository.kt
57+
[6]: app/src/main/java/com/android/example/paging/pagingwithnetwork/reddit/repository/inMemory/byPage/PageKeyedSubredditPagingSource.kt
58+
[7]: https://www.reddit.com/dev/api/#listings
6159
[mockwebserver]: https://github.com/square/okhttp/tree/master/mockwebserver
6260
[support-lib]: https://developer.android.com/topic/libraries/support-library/index.html
6361
[arch]: https://developer.android.com/arch

0 commit comments

Comments
 (0)