Java Code Examples for uk.co.senab.photoview.PhotoView#setOnPhotoTapListener()

The following examples show how to use uk.co.senab.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: NewsPhotoDetailActivity.java    From ZZShow with Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {

    PhotoView photoView = new PhotoView(NewsPhotoDetailActivity.this);
    Glide.with(NewsPhotoDetailActivity.this).load(mPictureList.get(position).getImgPath())
            .placeholder(R.mipmap.ic_loading)
            .error(R.mipmap.ic_load_fail)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .into(photoView);
    photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float v, float v1) {
            hideToolBarAndTextView();
            hideOrShowStatusBar();
        }

        @Override
        public void onOutsidePhotoTap() {

        }
    });
    container.addView(photoView, ViewPager.LayoutParams.MATCH_PARENT, ViewPager.LayoutParams.MATCH_PARENT);
    return photoView;
}
 
Example 2
Source File: ImagePickerPagerAdapter.java    From FamilyChat with Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position)
{
    PhotoView photoView = new PhotoView(mActivity);
    photoView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    photoView.setEnabled(true);
    ImageBean imageItem = mAllmageList.get(position);
    mImagePicker.getOptions().getDisplayer().display(mActivity, photoView, imageItem.getImagePath(), mScreenWidth, mScreenHeight);
    photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener()
    {
        @Override
        public void onPhotoTap(View view, float x, float y)
        {
            if (mListener != null)
                mListener.OnPhotoTapListener(view, x, y);
        }
    });
    container.addView(photoView);
    return photoView;
}
 
Example 3
Source File: SamplePagerAdapter.java    From KJGallery with Apache License 2.0 6 votes vote down vote up
/**
 * 加载普通图片
 */
private void displayImage(PhotoView photoView, byte[] res) {
    photoView.setVisibility(View.VISIBLE);

    Bitmap bitmap = byteArrayToBitmap(res);
    if (bitmap == null) {
        photoView.setImageResource(R.mipmap.default_img_rect);
    } else {
        photoView.setImageBitmap(bitmap);
    }

    photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            aty.finish();
        }
    });
}
 
Example 4
Source File: ImagePageAdapter.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    PhotoView photoView = new PhotoView(mActivity);
    ImageItem imageItem = images.get(position);
    imagePicker.getImageLoader().displayImages(mActivity, imageItem.path, photoView, screenWidth, screenHeight);
    photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            if (listener != null) listener.OnPhotoTapListener(view, x, y);
        }
    });
    container.addView(photoView);
    return photoView;
}
 
Example 5
Source File: ImagePageAdapter.java    From ImagePicker with Apache License 2.0 5 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    PhotoView photoView = new PhotoView(mActivity);
    ImageItem imageItem = images.get(position);
    imagePicker.getImageLoader().displayImagePreview(mActivity, imageItem.path, photoView, screenWidth, screenHeight);
    photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            if (listener != null) listener.OnPhotoTapListener(view, x, y);
        }
    });
    container.addView(photoView);
    return photoView;
}
 
Example 6
Source File: HxImageDetailAdapter.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position)
{
    PhotoView photoView = new PhotoView(mActivity);
    photoView.setBackgroundColor(Color.BLACK);
    photoView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    photoView.setEnabled(true);
    EMImageMessageBody messageBody = (EMImageMessageBody) mDataList.get(position).getBody();
    String localUrl = messageBody.getLocalUrl();
    String remoteUrl = messageBody.getRemoteUrl();
    if (StringUtil.isNotEmpty(localUrl) && new File(localUrl).exists())
        CommonUtils.getInstance().getImageDisplayer().display(mActivity, photoView, localUrl, mScreenWidth, mScreenHeight
                , R.drawable.pic_image_detail_place_holder, R.drawable.pic_image_detail_fail);
    else
        CommonUtils.getInstance().getImageDisplayer().display(mActivity, photoView, remoteUrl, mScreenWidth, mScreenHeight
                , R.drawable.pic_image_detail_place_holder, R.drawable.pic_image_detail_fail);

    photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener()
    {
        @Override
        public void onPhotoTap(View view, float x, float y)
        {
            if (mListener != null)
                mListener.OnPhotoTapListener(view, x, y);
        }
    });
    container.addView(photoView);
    return photoView;
}
 
Example 7
Source File: ImageViewActivity.java    From Fishing with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View instantiateItem(ViewGroup container, int position) {
    View view = LayoutInflater.from(ImageViewActivity.this).inflate(R.layout.item_imagepage, container, false);
    final PhotoView photoView = (PhotoView) view.findViewById(R.id.photoview);
    final View wheel = view.findViewById(R.id.wheel);
    photoView.setOnPhotoTapListener((view1, v, v1) -> finish());

    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(urls.get(position))
            .setResizeOptions(new ResizeOptions(768, 768))
            .build();
    DataSource<CloseableReference<CloseableImage>>
            dataSource = imagePipeline.fetchDecodedImage(request,this);
    DataSubscriber dataSubscriber = new BaseBitmapDataSubscriber() {
        @Override
        protected void onNewResultImpl(Bitmap bitmap) {
              photoView.setImageBitmap(bitmap);
              wheel.setVisibility(View.GONE);
        }

        @Override
        protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> closeableReferenceDataSource) {

        }
    };
    dataSource.subscribe(dataSubscriber, new Executor() {
        @Override
        public void execute(Runnable command) {
            handler.post(command);
        }
    });
    container.addView(view);
    return view;
}
 
Example 8
Source File: GalleryActivity.java    From HeartBeat with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);

    long eventId = getIntent().getLongExtra(EVENT_ID, -1);
    String path = "";
    if (eventId == -1) {
        path = getIntent().getStringExtra(PATH);
    }

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setBackgroundColor(Color.BLACK);
    toolbar.setTitle("");
    toolbar.setAlpha(0.6f);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mImage = (PhotoView) findViewById(R.id.imageview);

    mImage.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            finish();
        }
    });

    if (eventId != -1) {
        String imagePath = ImageUtils.getImageByEventId(this, eventId).getPath();
        Glide.with(this).load(GalleryUtils.getImagePath(imagePath)).into(mImage);
    } else {
        Glide.with(this).load(GalleryUtils.getImagePath(path)).into(mImage);
    }
}
 
Example 9
Source File: ImageActivity.java    From BlackLight with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onPostExecute(Object[] result) {
	super.onPostExecute(result);
	ViewGroup v = (ViewGroup) result[0];
	Object img = result[1];
	
	if (img != null) {
		v.removeAllViews();
		if (img instanceof Bitmap) {
			PhotoView p = new PhotoView(ImageActivity.this);
			
			// Disable hardware acceleration if too large
			Bitmap image = (Bitmap) img;
			int maxSize = Utility.getSupportedMaxPictureSize();
			if (image.getWidth() > maxSize || image.getHeight() > maxSize) {
				p.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
				
				if (DEBUG) {
					Log.d(TAG, "Image too large, hardware acceleration disabled. max size: " + maxSize);
				}
			}
			
			p.setImageBitmap(image);
			p.setOnPhotoTapListener(ImageActivity.this);
			v.addView(p, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
		} else if (img instanceof Movie) {
			GifView g = new GifView(ImageActivity.this);
			g.setMovie((Movie) img);
			v.addView(g, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
		}
	}
}
 
Example 10
Source File: ImageFragment.java    From OmniList with GNU Affero General Public License v3.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (attachment != null && Constants.MIME_TYPE_VIDEO.equals(attachment.getMineType())){
        RelativeLayout layout = new RelativeLayout(getContext());
        ImageView imageView = new ImageView(getContext());
        imageView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
        layout.addView(imageView);
        ImageView videoTip = new ImageView(getContext());
        videoTip.setImageResource(R.drawable.ic_play_circle_outline_white_24dp);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewUtils.dp2Px(getContext(), 50), ViewUtils.dp2Px(getContext(), 50));
        params.addRule(RelativeLayout.CENTER_IN_PARENT);
        videoTip.setLayoutParams(params);
        layout.addView(videoTip);
        displayMedia(imageView);
        return layout;
    }

    PhotoView photoView = new PhotoView(getContext());
    if (attachment != null && attachment.getUri().getPath().endsWith("gif")){
        Ion.with(getContext())
                .load(attachment.getUri().getPath())
                .intoImageView(photoView);
    } else {
        displayMedia(photoView);
    }
    photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            ((GalleryActivity) getActivity()).toggleSystemUI();
        }

        @Override
        public void onOutsidePhotoTap() {
            ((GalleryActivity) getActivity()).toggleSystemUI();
        }
    });
    photoView.setMaximumScale(5.0F);
    photoView.setMediumScale(3.0F);
    return photoView;
}