imbryk/LoopingViewPager

First and last Views getting destroyed even after using DEFAULT_BOUNDARY_CASHING true

Opened this issue · 3 comments

First and last Views getting destroyed even after using DEFAULT_BOUNDARY_CASHING true

Just call setOffscreenPageLimit() with you pager size.

setOffscreenPageLimit() should set adapter wrapper's count or real adapter's count ?

LoopPagerAdapterWrapper.destroyItem() has a bug: realPosition can be less than realFirst, which appears to be an unexpected situation. Changing if (mBoundaryCaching && (position == realFirst || position == realLast)) to if (mBoundaryCaching && (position <= realFirst || position >= realLast)) significantly improves the behaviour around destroying views.

A bug remains: when swiping backwards from the start, the last item is still recreated. This only happens the first time, however.

I was considering making a PR for the change, but given it's still buggy I thought I'd just contribute a suggestion, as I don't have the time to delve deeper now.