I am building a gallery app. I have an inner class in my MainActivity that extends PagerAdapter:
private class ImagePagerAdapter extends PagerAdapter{
@Override
public int getCount() {
return images.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
LinearLayout llImage = (LinearLayout) getLayoutInflater().inflate(R.layout.view_pager_item, null);
SubsamplingScaleImageView draweeView = (SubsamplingScaleImageView) llImage.getChildAt(0);
draweeView.setImage(ImageSource.uri(images.get(position)));
container.addView(llImage, 0);
return llImage;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((LinearLayout) object);
}
}
Items are created dynamically. My app allows user to zoom pictures in these pages (items), and ViewPager saves zoom state when I swipe to the next page. But when I return to previous page I want to see a picture in the default size without any changes.
How can I affect stored items when they comes to the screen again, considering that these items were created dynamically?