Back to project page works-imageview-pager.
The source code is released under:
Apache License
If you think the Android project works-imageview-pager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.mobilesolutionworks.android.imagepaging; /*from w w w .j av a 2 s . com*/ import android.content.Context; import android.support.v4.view.PagerAdapter; import android.util.SparseArray; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; /** * Created by yunarta on 18/9/14. */ public abstract class ImagePagerAdapter extends PagerAdapter { Context mContext; SparseArray<ImageViewTouchForPager> mImageViewPagerMap; public ImagePagerAdapter(Context context) { mContext = context; mImageViewPagerMap = new SparseArray<ImageViewTouchForPager>(); } protected abstract void setupImageView(ImageView imageView, int position); @Override public Object instantiateItem(ViewGroup container, int position) { ImageViewTouchForPager imageView = new ImageViewTouchForPager(mContext); // imageView.setDisplayType(ImageViewTouchBase.DisplayType.FIT_TO_SCREEN); mImageViewPagerMap.put(position, imageView); ImageViewPager pager = (ImageViewPager) container; ViewGroup.LayoutParams params = pager.generateDefaultLayoutParams(); params.width = container.getMeasuredWidth(); params.height = container.getMeasuredHeight(); container.addView(imageView, params); setupImageView(imageView, position); return imageView; } @Override public void destroyItem(ViewGroup container, int position, Object view) { container.removeView((View) view); mImageViewPagerMap.delete(position); } public ImageViewTouchForPager getImage(int position) { return mImageViewPagerMap.get(position); } @Override public void setPrimaryItem(ViewGroup container, int position, Object object) { super.setPrimaryItem(container, position, object); ImageViewTouchForPager pager; pager = mImageViewPagerMap.get(position - 1); if (pager != null) { pager.resetZoom(); } pager = mImageViewPagerMap.get(position + 1); if (pager != null) { pager.resetZoom(); } } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } public boolean allowPageScroll(int position) { // ImageViewTouchForPager imageView = mImageViewPagerMap.get(position); // return imageView.isHittingEdge(-dx) && imageView.isScrollable(); return false; } }