Java Code Examples for com.github.chrisbanes.photoview.PhotoView#setOnPhotoTapListener()

The following examples show how to use com.github.chrisbanes.photoview.PhotoView#setOnPhotoTapListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImagePreViewFragment.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
@Override
protected void initView() {
    display = (PhotoView) findViewById(R.id.pv_fragment_image_preview_display);
    display.setOnPhotoTapListener((view1, x, y) -> {
        getActivity().onBackPressed();
    });
    display.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            display.getViewTreeObserver().removeOnPreDrawListener(this);
            getActivity().supportStartPostponedEnterTransition();
            return true;
        }
    });
}
 
Example 2
Source File: PhotoPreViewAdapter.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, final int position) {
    View view = LayoutInflater.from(mContext).inflate(R.layout.item_activity_photo_preview, null);
    PhotoView photoView = view.findViewById(R.id.pv_item_activity_photo_preview_display);
    photoView.setOnPhotoTapListener((view1, x, y) -> {
        if (mOnPhotoViewClickListener != null) {
            mOnPhotoViewClickListener.onPhotoViewClick(view1, position);
        }
    });
    SystemUtil.ImageItem imageItem = data.get(position);
    String url = imageItem.getPath();
    if (url != null) {
        if (url.endsWith(".gif")) {
            BaseApplication
                    .getAppComponent()
                    .getImageLoader().loadImage(mContext
                    , GlideImageLoaderConfig.newBuild().cacheStrategy(GlideImageLoaderConfig.CACHE_SOURCE)
                            .asGif().override(screenWidth, screenHeight).imageView(photoView).url(url).build());
        } else {
            BaseApplication
                    .getAppComponent()
                    .getImageLoader().loadImage(mContext
                    , GlideImageLoaderConfig.newBuild().cacheStrategy(GlideImageLoaderConfig.CACHE_RESULT).centerInside().url(url).imageView(photoView).build());
        }
    }
    container.addView(view);
    return view;
}
 
Example 3
Source File: PictureFragment.java    From Simpler with Apache License 2.0 5 votes vote down vote up
private void initView(FrameLayout frameLayout) {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    layoutParams.gravity = Gravity.CENTER;
    /* 图片加载进度圈 */
    CircleProgress progress = getProgressView(getActivity());
    mProgressModelLoader = new ProgressModelLoader(getHandler(progress));

    if (url.endsWith(".gif")) {
        GifMovieView gifView = new GifMovieView(frameLayout.getContext());
        gifView.setLayoutParams(layoutParams);
        gifView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 点击图片返回
                getActivity().onBackPressed();
            }
        });
        frameLayout.addView(gifView);
        progress.inject(gifView);
        loadPic(url, gifView, true);
    } else {
        PhotoView photoView = new PhotoView(frameLayout.getContext());
        photoView.setLayoutParams(layoutParams);
        photoView.setOnPhotoTapListener(new OnPhotoTapListener() {
            @Override
            public void onPhotoTap(ImageView view, float x, float y) {
                // 点击图片返回
                getActivity().onBackPressed();
            }
        });
        frameLayout.addView(photoView);
        progress.inject(photoView);
        loadPic(url, photoView, false);
    }
}
 
Example 4
Source File: ViewBigImageActivity.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
    View view = getLayoutInflater().inflate(R.layout.viewpager_very_image, container, false);
    PhotoView zoomImageView = view.findViewById(R.id.zoom_image_view);
    ProgressBar spinner = view.findViewById(R.id.loading);
    spinner.setVisibility(View.GONE);
    if (imageId != 0) {
        zoomImageView.setImageResource(imageId);
    }
    zoomImageView.setOnPhotoTapListener(ViewBigImageActivity.this);
    container.addView(view, 0);
    return view;
}