[Sample] Handle crash issue after tapping on the Search Tab. #2339
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.
In order to fix the issue, i needed to tweak with the getRefreshKey method which makes sure it returns a valid Int value. Earlier it was throwing a ClassCastException . But now, the method calculates & returns a refresh key based on the current state of paging data. It uses the anchor position to find the closest page, then checks if there is a previous key available. If there is, it increments it by 1. If the previous key is null, it checks if there is a next key available. If there is, it decrements it by 1. The resulting value represents the refresh key or null if both previous and next keys are null.
Before:
https://github.com/airbnb/lottie-android/assets/8761426/4d24bbcf-44a1-4011-902a-da3b582e437f
After:
https://github.com/airbnb/lottie-android/assets/8761426/b9efebb6-534c-4b89-a354-f857e662b499