@Override public Object instantiateItem(ViewGroup container, int position) { FrameLayout page = (FrameLayout) container.getChildAt(position); if (page == null) { return null; } ZoomableDraweeView zoomableDraweeView = (ZoomableDraweeView) page.findViewById(R.id.zoomableView); zoomableDraweeView.setAllowTouchInterceptionWhileZoomed(mAllowSwipingWhileZoomed); // needed for double tap to zoom zoomableDraweeView.setIsLongpressEnabled(false); zoomableDraweeView.setTapListener(new DoubleTapGestureListener(zoomableDraweeView)); DraweeController controller = Fresco.newDraweeControllerBuilder() .setUri(SAMPLE_URIS[position % SAMPLE_URIS.length]) .setCallerContext("ZoomableApp-MyPagerAdapter") .build(); zoomableDraweeView.setController(controller); page.requestLayout(); return page; }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_gallery_item, container, false); progressBar = rootView.findViewById(R.id.gallery_item_progress_bar); videoContainer = rootView.findViewById(R.id.gallery_video_container); videoView = rootView.findViewById(R.id.gallery_video); videoThumbnail = rootView.findViewById(R.id.gallery_video_thumbnail); videoPlayButton = rootView.findViewById(R.id.gallery_video_play_button); imageView = rootView.findViewById(R.id.gallery_image); imageView.setTapListener(new DoubleTapGestureListener(imageView) { @Override public boolean onSingleTapConfirmed(MotionEvent e) { parentActivity.toggleControls(); return true; } }); GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources()) .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER) .build(); imageView.setHierarchy(hierarchy); return rootView; }