Android-ObservableScrollView icon indicating copy to clipboard operation
Android-ObservableScrollView copied to clipboard

scrollY value incorrect with reversed LinearLayoutManager

Open xitij opened this issue 8 years ago • 0 comments

Hi, First of all great library, it's really useful.

I'm using this library in combination with modified version of FlexibleSpaceWithImageWithViewPagerTabActivity that multiple modified versions of FlexibleSpaceWithImageRecyclerViewFragments. My modified Fragments use a LinearLayoutManager with setReverseLayout = true (newest data at the bottom). When attempting to scroll back (show older items) the FlexibleSpace collapses to a point (while scrolling) until it random pops back open.

After doing so sleuthing I determined that the scrollY value is incorrect. First of all it starts at a large negative number. I noticed that once the first item is no longer visible (off the screen at the bottom) the scrollY will increase (less negative) which causes some erratic behavior in the header.

I forked the library myself and determined that in ObservableRecyclerView when setting the scrollY it is always checking childView.getTop(). This is incorrect for layouts that are reversed. I realize that reversing the layout might be a small use case (since it's only possible with LinearLayoutManager and a RecyclerView) but I figured I'd post this here to see your thoughts.

In my fork of the library I believe I managed to fix the bug. I can submit a PR if you'd like or other people find this useful.

Please let me know if you understand the issue as raised. Thanks again the great library.

xitij avatar Jun 22 '16 04:06 xitij