fix: prevent deck overlap by skipping redundant scroll for visible items#20406
Open
Ayush-Patel-56 wants to merge 1 commit intoankidroid:mainfrom
Open
fix: prevent deck overlap by skipping redundant scroll for visible items#20406Ayush-Patel-56 wants to merge 1 commit intoankidroid:mainfrom
Ayush-Patel-56 wants to merge 1 commit intoankidroid:mainfrom
Conversation
Member
|
What's the debug info of the emulator you used to test? Tapping an empty deck should show the congrats screen successfully |
Contributor
Author
|
Debug Info: Congrats Screen: I have verified the Congrats Screen on both a emulator (API 30) and a modern device.
|
|
|
||
| fun onFocusedDeckChanged(deckId: DeckId?) { | ||
| val position = deckId?.let { viewModel.findDeckPosition(it) } ?: 0 | ||
| val firstVisible = decksLayoutManager.findFirstVisibleItemPosition() |
Member
There was a problem hiding this comment.
Explain why this occurs to a reader.
- Add a comment,
- Optionally add a
LinearLayoutManager.positionIsVisible(position: Int)method so the intent of the code is obvious
if (decksLayoutManager.positionIsVisible(position)) {
return
}
Contributor
Author
There was a problem hiding this comment.
Added the positionIsVisible helper to LinearLayoutManager.kt as suggested. Also put in a short comment explaining the issue.
3d021cd to
c101225
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose / Description
Fixes visual overlapping of deck names/counts when a deck is tapped.
Fixes
Approach
Skips the programmatic centering scroll if the deck is already visible to the user. This avoids a layout conflict between the scroll and the adapter's repaint.
How Has This Been Tested?
Verified on Android 11 (API 30) emulator. Taps on visible decks are now smooth without glitches, and secondary focus (returning from reviewer) still centers correctly.
555479092-e320972d-6637-417e-9dcd-c93c9d616f72.mp4
Checklist