-
Notifications
You must be signed in to change notification settings - Fork 255
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
V3 paging loadstate #195
Open
evant
wants to merge
14
commits into
main
Choose a base branch
from
v3-paging-loadstate
base: main
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
V3 paging loadstate #195
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
321de43
Jetpack paging v3
kedzie bff5bfa
load state adapters
kedzie adbef87
fix sample PagingSource
kedzie 076cc24
add header load state to sample
kedzie 4d78d13
rename sample load state adapter
kedzie b594ea3
revert debuggable
kedzie 251b304
handle case without diff util. disable placeholders in sample to sho…
kedzie 075aafe
clean up diff
kedzie 77df2ba
update default diff
kedzie b8b0a66
Support paging LoadState with a dedicated list and binding
evant ecd608f
retry/refresh support (#196)
kedzie 600451f
Merge branch 'main' into v3-paging-loadstate
evant a7555a1
Bump paging version
evant d14302c
Fix test
evant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
app/src/main/java/me/tatarka/bindingcollectionadapter/sample/FragmentPagedV3RecyclerView.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package me.tatarka.bindingcollectionadapter.sample | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import androidx.lifecycle.ViewModelProviders | ||
import androidx.lifecycle.get | ||
import me.tatarka.bindingcollectionadapter.sample.databinding.PagedV3RecyclerViewBinding | ||
|
||
class FragmentPagedV3RecyclerView : Fragment() { | ||
private lateinit var viewModel: ImmutableViewModel | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
viewModel = ViewModelProviders.of(this).get() | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
return PagedV3RecyclerViewBinding.inflate(inflater, container, false).also { | ||
it.setLifecycleOwner(this) | ||
it.viewModel = viewModel | ||
it.listeners = viewModel | ||
it.executePendingBindings() | ||
}.root | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
~ Copyright (C) 2017 The Android Open Source Project | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<data> | ||
|
||
<import type="android.view.View" /> | ||
|
||
<variable | ||
name="load" | ||
type="me.tatarka.bindingcollectionadapter2.itembindings.Load" /> | ||
</data> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:padding="8dp"> | ||
|
||
<TextView | ||
android:id="@+id/error_msg" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:text="@{load.error.message}" | ||
android:visibility="@{load.isError() ? View.VISIBLE : View.GONE}" /> | ||
|
||
<ProgressBar | ||
android:id="@+id/progress_bar" | ||
style="?android:attr/progressBarStyle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:visibility="@{load.isLoading() ? View.VISIBLE : View.GONE}" /> | ||
|
||
<Button | ||
android:id="@+id/retry_button" | ||
style="@style/Widget.AppCompat.Button.Colored" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:text="@string/retry" | ||
android:visibility="@{load.isError() ? View.VISIBLE : View.GONE}" /> | ||
</LinearLayout> | ||
|
||
</layout> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<data> | ||
|
||
<import type="me.tatarka.bindingcollectionadapter.sample.ImmutableItem" /> | ||
|
||
<variable | ||
name="viewModel" | ||
type="me.tatarka.bindingcollectionadapter.sample.ImmutableViewModel" /> | ||
|
||
<variable | ||
name="listeners" | ||
type="me.tatarka.bindingcollectionadapter.sample.Listeners" /> | ||
</data> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/list" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:layout_weight="1" | ||
app:diffConfig="@{viewModel.diff}" | ||
app:itemBinding="@{viewModel.loadStateItems}" | ||
app:items="@{viewModel.pagedListV3}" | ||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> | ||
</LinearLayout> | ||
</layout> |
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
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
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
Oops, something went wrong.
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.
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.
Can we split this into its own
OnItemBindClass
? so we can separate the layouts for error/progress casesThere 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.
Ideally would look like this
But in this case our item is
Load
notLoadState.Error
..