LoopingViewPager
LoopingViewPager copied to clipboard
BoundaryCaching and dataChange
Hi, I've faced a problem, when if boundaryCaching is set to true and notifyDataSetChanged() is called, first and last elements of viewpager become unpredictable. In my situation, after updating the viewpager current item was replaced by first element, so duplicates appeared in view pager. I've fixed it by forcing adapter to destroy all existing toDestroy objects while doing notifyDataSetChanged(). So maybe it should be included to library too.
LoopPagerAdapterWrapper:
public void notifyDataSetChanged() {
for(int i = 0; i < mToDestroy.size(); i++){
ToDestroy value = mToDestroy.valueAt(i);
mAdapter.destroyItem(value.container, value.position, value.object);
}
mToDestroy = new SparseArray<ToDestroy>();
super.notifyDataSetChanged();
}