Skip to content
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

Don't throw exception on empty data in AndroidX Paging3 extension #2219

Merged
merged 1 commit into from
Mar 29, 2021
Merged

Don't throw exception on empty data in AndroidX Paging3 extension #2219

merged 1 commit into from
Mar 29, 2021

Conversation

veyndan
Copy link
Collaborator

@veyndan veyndan commented Mar 29, 2021

I'm just trying out the new AndroidX Paging3 extension and I'm getting an IndexOutOfBoundsException when my table is empty (i.e., countQuery.executeAsOne() == 0). I'm new to the Paging3 library, but I'd assume that the table being empty shouldn't throw an exception.

@AlecKazakova
Copy link
Collaborator

@kevincianfarini

@AlecKazakova AlecKazakova merged commit de0ad1a into cashapp:master Mar 29, 2021
@veyndan veyndan deleted the fix/paging3-empty-page branch March 29, 2021 20:16
@@ -37,7 +37,7 @@ internal class OffsetQueryPagingSource<RowType : Any>(
val key = params.key ?: 0L
transacter.transactionWithResult {
val count = countQuery.executeAsOne()
if (key >= count) throw IndexOutOfBoundsException()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a filtering applied (show only unread items). When I mark an item as read obviously count is smaller than key and I'd expect that item to disappear. Paging2 source handled this perfectly well, what's the reason for throwing here @kevincianfarini ? Does paging3 not support items being removed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are you marking the item as read? If you're mutating a row in the database, I would expect this paging source to get invalidated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I am mutating a row in the database. I found a way to make this work in #2913 for me locally (there's some more information)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants