sunflower
sunflower copied to clipboard
[ Fix ]: App Crash when scroll to page 2 in Gallery Screen
When the first page is loaded, pageSize=75 https://api.unsplash.com/search/photos?query=Apple&page=1&per_page=75
When the second page is loaded, pageSize=25 https://api.unsplash.com/search/photos?query=Apple&page=2&per_page=25
Duplicate data on the first and second pages
FATAL EXCEPTION: main
Process: com.google.samples.apps.sunflower, PID: 8802
java.lang.IllegalArgumentException: Key "P2X7NDx_GP0" was already used. If you are using LazyColumn/Row please make sure you provide a unique key for each item.
So App Crash when scroll to page 2 in Gallery Screen
Here's my solution, Specify the value of initialLoadSize explicitly
fun getSearchResultStream(query: String): Flow<PagingData<UnsplashPhoto>> {
return Pager(
config = PagingConfig(enablePlaceholders = false, pageSize = NETWORK_PAGE_SIZE, initialLoadSize = NETWORK_PAGE_SIZE),
pagingSourceFactory = { UnsplashPagingSource(service, query) }
).flow
}
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
Hi, Thanks for your contribution, however Sunflower is going to be archived in favour of maintaining a smaller set of up-to-date set of compose-samples, that can be found here: https://github.com/android/compose-samples, as well as snippets that can be found here: https://github.com/android/snippets.
Please feel free to keep your fork up-to-date for your learning, but this repository will be archived shortly.