BeksOmega / looping-layout

A looping LayoutManager for the Android RecyclerView.
Apache License 2.0
274 stars 16 forks source link

Add Functions for Getting the Adapter Index of a View at an Important Position #46

Closed BeksOmega closed 3 years ago

BeksOmega commented 3 years ago

:key: Use case

Being able to get the adapter index of the view at the very start or end of layout is important if you want to implement any sort of animation using scrollToPosition. For an example see sergijuanola's code snippet.

:hammer: Proposal

The LoopingLayoutManager should provide the following (new) functions, in the same way that the LinearLayoutManager does:

To close this issue each function also needs tests to ensure it works properly (including accounting for duplicate views with the same adapter index).

(Note that I hate these names, but I want to match the LinearLayoutManager for consistency)

:wrench: Alternative

N/A

:memo: Other info

Inspired by #45

Here are some links to relevant bits of source code: findOneVisibleChild from LinearLayoutManager (the functions listed above call this function) findOneViewWithinBoundFlags from ViewBoundsCheck (eventually the calls from the LayoutManager get passed here)

This logic /probably/ won't work with the LoopingLayoutManager because we have to deal with duplicates, but they might be useful. Other useful things for implementing this functionality include:

:bee: Request for assignment

This issue is ready to be worked on! Feel free to work on each function individually if that's easier. Just be sure to claim the issue as specified in the contribution guidelines =)

BeksOmega commented 3 years ago

I'll take this one.

BeksOmega commented 3 years ago

Closed via #54