-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
05-paging #12
Open
Serchinastico
wants to merge
1
commit into
04-live-data-and-view-model
Choose a base branch
from
05-paging
base: 04-live-data-and-view-model
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
05-paging #12
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
davideme
reviewed
Feb 6, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @Serchinastico !!!!
app/src/main/java/com/karumi/jetpack/superheroes/data/repository/SuperHeroesBoundaryCallback.kt
Show resolved
Hide resolved
app/src/main/java/com/karumi/jetpack/superheroes/data/repository/LocalSuperHeroDataSource.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/karumi/jetpack/superheroes/data/repository/LocalSuperHeroDataSource.kt
Outdated
Show resolved
Hide resolved
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
from
February 6, 2019 12:13
ed51a17
to
e5b3c72
Compare
Serchinastico
force-pushed
the
05-paging
branch
from
February 6, 2019 12:13
ff02017
to
7723fb5
Compare
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
from
February 6, 2019 14:21
e5b3c72
to
592849a
Compare
Serchinastico
force-pushed
the
05-paging
branch
4 times, most recently
from
February 6, 2019 17:14
320c8d6
to
190583a
Compare
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
from
March 15, 2019 11:32
592849a
to
2a59248
Compare
Serchinastico
force-pushed
the
05-paging
branch
from
March 15, 2019 11:32
190583a
to
c84a4dc
Compare
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
from
March 15, 2019 16:38
2a59248
to
d9da96b
Compare
Serchinastico
force-pushed
the
05-paging
branch
from
March 15, 2019 16:38
c84a4dc
to
8f2526c
Compare
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
2 times, most recently
from
March 15, 2019 17:02
7482884
to
6100eb2
Compare
Serchinastico
force-pushed
the
05-paging
branch
from
March 15, 2019 17:16
8f2526c
to
7072c5f
Compare
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
from
March 15, 2019 17:32
6100eb2
to
5a956ff
Compare
Serchinastico
force-pushed
the
05-paging
branch
from
March 15, 2019 17:33
7072c5f
to
e22c667
Compare
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
from
March 15, 2019 17:35
5a956ff
to
e80f6af
Compare
Serchinastico
force-pushed
the
05-paging
branch
from
March 15, 2019 17:35
e22c667
to
2b69a6f
Compare
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
from
March 15, 2019 17:45
e80f6af
to
2fa910d
Compare
Serchinastico
force-pushed
the
05-paging
branch
from
March 15, 2019 17:45
2b69a6f
to
58e6a2b
Compare
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
from
March 15, 2019 18:42
2fa910d
to
46cf2b2
Compare
Serchinastico
force-pushed
the
05-paging
branch
from
March 15, 2019 18:43
58e6a2b
to
6d0ed15
Compare
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
from
May 21, 2019 10:29
46cf2b2
to
7ac91df
Compare
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
from
May 21, 2019 15:53
7ac91df
to
dd31b7c
Compare
Serchinastico
force-pushed
the
04-live-data-and-view-model
branch
from
May 22, 2019 16:44
dd31b7c
to
e3f613c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is not meant to be merged
This is how to use the Paging component:
PagedList
instead of a simpleList
of elements (in this case,SuperHero
). Room already gives support to it and deals with pagination for you but it's up to the developer to have a backing data source that supports pagination.BoundaryCallback
implementation. It is called whenever theLivePagedListBuilder
created in the local data source runs out of elements. It has to fetch the new elements from somewhere, in our case from theRemoteSuperHeroDataSource
and store them in theLocalSuperHeroDataSource
. The API is too simple as it only returns the last item it found, that means that we have to deal with knowing what page is that in our system. In this PR we are just storing an index that is increasing with every new fetch but if the application would be more complex we'd have to create a fancier mechanism. BTW, the callback is a repository dependency because if I'd add it as a dependency of the local data source I'd be creating a dependency cycle.RecyclerView.Adapter
by aPagedListAdapter
. It is this element the one really firing the event in case we need more elements. It relies on you calling thegetItem
method so you are forced to call it from your implementation adapter even if it's not used.