Fixed
Status Update
Comments
jd...@xooloo.com <jd...@xooloo.com> #2
Just to let you know that this issue present in the latest available release. I did just update to alpha09 and it breaks my code. My PagingSource if a Room backed source, but I have the same issue: the paging library failed to generate a separator for the first item.
It is still working with the alpha08.
du...@google.com <du...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit aa90cc2cb835209e12964d3afbc91e96b6d4e36b
Author: Dustin Lam <dustinlam@google.com>
Date: Tue Nov 24 11:34:08 2020
Add empty terminal insert for separators support with RemoteMediator
Re-applies a previous hack which inserted empty insert events to allow
separators to add terminal separators (header / footer), since
Separators may need to wait for a LoadStateUpdate event to mark terminal
load state from RemoteMediator.
Fixes: 172254056
Test: ./gradlew paging:paging-common:test
Change-Id: I5c5f2ac3860889909a30cd322a1e7b36eec1a9fd
M paging/common/src/main/kotlin/androidx/paging/MutableLoadStateCollection.kt
M paging/common/src/main/kotlin/androidx/paging/PageEvent.kt
M paging/common/src/main/kotlin/androidx/paging/PageFetcher.kt
M paging/common/src/main/kotlin/androidx/paging/Separators.kt
M paging/common/src/test/kotlin/androidx/paging/PageFetcherSnapshotTest.kt
M paging/common/src/test/kotlin/androidx/paging/SeparatorsTest.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/room/CustomerDao.java
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3room/NetworkCustomerPagingSource.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3room/V3RemoteMediator.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3room/V3RoomAdapter.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3room/V3RoomViewModel.kt
https://android-review.googlesource.com/1510174
Branch: androidx-master-dev
commit aa90cc2cb835209e12964d3afbc91e96b6d4e36b
Author: Dustin Lam <dustinlam@google.com>
Date: Tue Nov 24 11:34:08 2020
Add empty terminal insert for separators support with RemoteMediator
Re-applies a previous hack which inserted empty insert events to allow
separators to add terminal separators (header / footer), since
Separators may need to wait for a LoadStateUpdate event to mark terminal
load state from RemoteMediator.
Fixes: 172254056
Test: ./gradlew paging:paging-common:test
Change-Id: I5c5f2ac3860889909a30cd322a1e7b36eec1a9fd
M paging/common/src/main/kotlin/androidx/paging/MutableLoadStateCollection.kt
M paging/common/src/main/kotlin/androidx/paging/PageEvent.kt
M paging/common/src/main/kotlin/androidx/paging/PageFetcher.kt
M paging/common/src/main/kotlin/androidx/paging/Separators.kt
M paging/common/src/test/kotlin/androidx/paging/PageFetcherSnapshotTest.kt
M paging/common/src/test/kotlin/androidx/paging/SeparatorsTest.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/room/CustomerDao.java
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3room/NetworkCustomerPagingSource.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3room/V3RemoteMediator.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3room/V3RoomAdapter.kt
M paging/integration-tests/testapp/src/main/java/androidx/paging/integration/testapp/v3room/V3RoomViewModel.kt
Description
I'm using a custom PagingSource backed by a SparseArray and a RemoteMediator to feed the SparseArray when more items are needed and invalidates the PagingSource.
With the alpha08 version of Paging, I was having the same bug as the one reported by 172000108, but the insertSeparators function was working fine (I'm just displaying a header before each item).
With the snapshot version, it is not crashing anymore, but the insertSeparators is not inserting a header before the first item in the list.
It seems to me that it is related to the new terminatesStart function in Separators.kt on CombinedLoadStates. When I use a PagingSource generated by Room, it returns true, and the headers are all displayed.
But with a remote mediator, it returns false, that's why the first header might not displayed.
My remote mediator is first called with loadType REFRESH then with PREPEND (i always return endOfPaginationReached = true for this case, as I only append items). So the mediator.prepend of CombinedLoadStates is eventually terminal (first NotLoading(endOfPaginationReached = false) then NotLoading(endOfPaginationReached = true).
But my PagingSource is never called with a params Prepend (I would return an empty list and both null for prev and next keys if it was called). So source.prepend is never terminal (always NotLoading(endOfPaginationReached = false).