Skip to content

Conversation

@karanrajak19
Copy link

Refactored PickerLayoutManager to improve how items scale and how the selected item is determined. Previously, the scaling logic wasn’t as smooth as it could be, so I tweaked it to ensure a more natural effect when scrolling. I also replaced the old method of selecting the most visible item with a new approach that accurately finds the item closest to the center using getCenteredView(), which makes selection much more precise.

Added a setCurrentItem() method that lets me programmatically scroll to a specific item, either instantly or with smooth scrolling. It also includes checks to prevent crashes if an invalid index is passed.

To make things more stable, I wrapped onLayoutChildren() in a try-catch block to prevent crashes and added proper logging so errors can be debugged easily. Also cleaned up the code a bit—renamed some variables, added @nonnull annotations, and reformatted things to make it more readable. Overall, these changes make PickerLayoutManager more reliable and easier to use.

Refactored PickerLayoutManager to improve how items scale and how the selected item is determined. Previously, the scaling logic wasn’t as smooth as it could be, so I tweaked it to ensure a more natural effect when scrolling. I also replaced the old method of selecting the most visible item with a new approach that accurately finds the item closest to the center using getCenteredView(), which makes selection much more precise.

Added a setCurrentItem() method that lets me programmatically scroll to a specific item, either instantly or with smooth scrolling. It also includes checks to prevent crashes if an invalid index is passed.

To make things more stable, I wrapped onLayoutChildren() in a try-catch block to prevent crashes and added proper logging so errors can be debugged easily. Also cleaned up the code a bit—renamed some variables, added @nonnull annotations, and reformatted things to make it more readable. Overall, these changes make PickerLayoutManager more reliable and easier to use.
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.

1 participant