it.sephiroth.android.library.imagezoom.ImageViewTouch Java Examples

The following examples show how to use it.sephiroth.android.library.imagezoom.ImageViewTouch. 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: ImageDecryptActivity.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_decrypt_image);

    mVgError = (ViewGroup) findViewById(R.id.vg_error);
    mTvError = (TextView) findViewById(R.id.tv_error);
    mVgUpgrade = (ViewGroup) findViewById(R.id.vg_upgrade_reminder);
    mVgProgress = (ViewGroup) findViewById(R.id.vg_progress);
    mVgMain = (ViewGroup) findViewById(R.id.vg_main);
    mIvFull = (ImageViewTouch) findViewById(R.id.iv_full);
    mIvThumb = (ImageView) findViewById(R.id.iv_thumb);


    if (savedInstanceState != null) {
        mZoomedIn = savedInstanceState.getBoolean(EXTRA_ZOOMED);
    }
    init();
}
 
Example #2
Source File: TouchImageView.java    From touch-image-view with MIT License 6 votes vote down vote up
@Override
protected GestureDetector.OnGestureListener getGestureListener() {
    return new ImageViewTouch.GestureListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            mUserScaled = true;

            float scale = getScale();
            float targetScale = onDoubleTapPost(scale, getMaxScale(), getMinScale());
            targetScale = Math.min(getMaxScale(), Math.max(targetScale, getMinScale()));
            zoomTo(targetScale, e.getX(), e.getY(), (long) mDefaultAnimationDuration);

            if (null != mDoubleTapListener) {
                mDoubleTapListener.onDoubleTap();
            }

            return false;
        }
    };
}
 
Example #3
Source File: PreviewViewPager.java    From AlbumCameraRecorder with MIT License 5 votes vote down vote up
@Override
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ImageViewTouch) {
        return ((ImageViewTouch) v).canScroll(dx) || super.canScroll(v, checkV, dx, x, y);
    }
    return super.canScroll(v, checkV, dx, x, y);
}
 
Example #4
Source File: PreviewItemFragment.java    From Matisse with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final Item item = getArguments().getParcelable(ARGS_ITEM);
    if (item == null) {
        return;
    }

    View videoPlayButton = view.findViewById(R.id.video_play_button);
    if (item.isVideo()) {
        videoPlayButton.setVisibility(View.VISIBLE);
        videoPlayButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(item.uri, "video/*");
                try {
                    startActivity(intent);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(getContext(), R.string.error_no_video_activity, Toast.LENGTH_SHORT).show();
                }
            }
        });
    } else {
        videoPlayButton.setVisibility(View.GONE);
    }

    ImageViewTouch image = (ImageViewTouch) view.findViewById(R.id.image_view);
    image.setDisplayType(ImageViewTouchBase.DisplayType.FIT_TO_SCREEN);

    Point size = PhotoMetadataUtils.getBitmapSize(item.getContentUri(), getActivity());
    if (item.isGif()) {
        SelectionSpec.getInstance().imageEngine.loadGifImage(getContext(), size.x, size.y, image,
                item.getContentUri());
    } else {
        SelectionSpec.getInstance().imageEngine.loadImage(getContext(), size.x, size.y, image,
                item.getContentUri());
    }
}
 
Example #5
Source File: PreviewViewPager.java    From Matisse with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ImageViewTouch) {
        return ((ImageViewTouch) v).canScroll(dx) || super.canScroll(v, checkV, dx, x, y);
    }
    return super.canScroll(v, checkV, dx, x, y);
}
 
Example #6
Source File: PreviewViewPager.java    From Matisse with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ImageViewTouch) {
        return ((ImageViewTouch) v).canScroll(dx) || super.canScroll(v, checkV, dx, x, y);
    }
    return super.canScroll(v, checkV, dx, x, y);
}
 
Example #7
Source File: PreviewItemFragment.java    From AlbumCameraRecorder with MIT License 4 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final MultiMedia item = getArguments().getParcelable(ARGS_ITEM);
    if (item == null) {
        return;
    }

    View videoPlayButton = view.findViewById(R.id.video_play_button);
    if (item.isVideo()) {
        videoPlayButton.setVisibility(View.VISIBLE);
        videoPlayButton.setOnClickListener(v -> {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            Uri uri = null;
            if (item.getMediaUri() != null) {
                uri = item.getMediaUri();
            }else if(item.getUri() != null) {
                item.setMediaUri(FileUtil.getFileUri(getContext(),item.getType(),new File(item.getPath())));
                uri = item.getMediaUri();
            }
            intent.setDataAndType(uri, "video/*");
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(getContext(), R.string.error_no_video_activity, Toast.LENGTH_SHORT).show();
            }
        });
    } else {
        videoPlayButton.setVisibility(View.GONE);
    }

    ImageViewTouch image = view.findViewById(R.id.image_view);
    image.setDisplayType(ImageViewTouchBase.DisplayType.FIT_TO_SCREEN);

    if (item.getMediaUri() != null) {
        Point size = PhotoMetadataUtils.getBitmapSize(item.getMediaUri(), getActivity());
        if (item.isGif()) {
            GlobalSpec.getInstance().imageEngine.loadGifImage(getContext(), size.x, size.y, image,
                    item.getMediaUri());
        } else {
            GlobalSpec.getInstance().imageEngine.loadImage(getContext(), size.x, size.y, image,
                    item.getMediaUri());

        }
    } else if (item.getUri() != null) {
        GlobalSpec.getInstance().imageEngine.loadUriImage(getContext(), image,
                item.getUri());
    } else if (item.getUrl() != null) {
        GlobalSpec.getInstance().imageEngine.loadUrlImage(getContext(), image,
                item.getUrl());
    } else if (item.getDrawableId() != -1) {
        GlobalSpec.getInstance().imageEngine.loadDrawableImage(getContext(), image,
                item.getDrawableId());
    }


}
 
Example #8
Source File: PreviewItemFragment.java    From AlbumCameraRecorder with MIT License 4 votes vote down vote up
public void resetView() {
    if (getView() != null) {
        ((ImageViewTouch) getView().findViewById(R.id.image_view)).resetMatrix();
    }
}
 
Example #9
Source File: PreviewItemFragment.java    From Matisse with Apache License 2.0 4 votes vote down vote up
public void resetView() {
    if (getView() != null) {
        ((ImageViewTouch) getView().findViewById(R.id.image_view)).resetMatrix();
    }
}
 
Example #10
Source File: PreviewItemFragment.java    From Matisse with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final Item item = getArguments().getParcelable(ARGS_ITEM);
    if (item == null) {
        return;
    }

    View videoPlayButton = view.findViewById(R.id.video_play_button);
    if (item.isVideo()) {
        videoPlayButton.setVisibility(View.VISIBLE);
        videoPlayButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(item.uri, "video/*");
                try {
                    startActivity(intent);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(getContext(), R.string.error_no_video_activity, Toast.LENGTH_SHORT).show();
                }
            }
        });
    } else {
        videoPlayButton.setVisibility(View.GONE);
    }

    ImageViewTouch image = (ImageViewTouch) view.findViewById(R.id.image_view);
    image.setDisplayType(ImageViewTouchBase.DisplayType.FIT_TO_SCREEN);

    image.setSingleTapListener(new ImageViewTouch.OnImageViewTouchSingleTapListener() {
        @Override
        public void onSingleTapConfirmed() {
            if (mListener != null) {
                mListener.onClick();
            }
        }
    });

    Point size = PhotoMetadataUtils.getBitmapSize(item.getContentUri(), getActivity());
    if (item.isGif()) {
        SelectionSpec.getInstance().imageEngine.loadGifImage(getContext(), size.x, size.y, image,
                item.getContentUri());
    } else {
        SelectionSpec.getInstance().imageEngine.loadImage(getContext(), size.x, size.y, image,
                item.getContentUri());
    }
}
 
Example #11
Source File: PreviewItemFragment.java    From Matisse with Apache License 2.0 4 votes vote down vote up
public void resetView() {
    if (getView() != null) {
        ((ImageViewTouch) getView().findViewById(R.id.image_view)).resetMatrix();
    }
}
 
Example #12
Source File: TouchImageView.java    From touch-image-view with MIT License 4 votes vote down vote up
public void setDoubleTapListener(ImageViewTouch.OnImageViewTouchDoubleTapListener listener) {
    this.mDoubleTapListener = listener;
}
 
Example #13
Source File: ImageFragment.java    From Klyph with MIT License 4 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState)
{
	progress = (ProgressBar) view.findViewById(R.id.progress);
	emptyView = (ListEmptyView) view.findViewById(R.id.emptyView);
	imageView = (ImageViewTouch) view.findViewById(R.id.image);

	slidingDrawer = (KlyphSlidingDrawer) view.findViewById(R.id.sliding_drawer);

	captionInfo = (ViewGroup) view.findViewById(R.id.caption_info);
	profileImage = (ImageView) view.findViewById(R.id.author_profile_image);
	authorName = (TextView) view.findViewById(R.id.author_name);
	postTime = (TextView) view.findViewById(R.id.post_time);

	sendTextEdit = (EditText) view.findViewById(R.id.send_text_edit);
	sendButton = (ImageButton) view.findViewById(R.id.send_button);

	emptyView.setText(R.string.cannot_find_photo);

	getListView().setCacheColorHint(AttrUtil.getColor(getActivity(), android.R.attr.windowBackground));

	// imageView.setOnScaleListener(this);
	imageView.setSingleTapListener(new ImageViewTouch.OnImageViewTouchSingleTapListener() {

		@Override
		public void onSingleTapConfirmed()
		{
			toggleBarVisibility();
		}
	});

	sendButton.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View v)
		{
			handlePostComment();
		}
	});

	defineEmptyText(R.string.no_comment);

	adapter = new MultiObjectAdapter(getListView(), SpecialLayout.PHOTO);
	setListAdapter(adapter);

	// setRequestType(Query.PHOTO_AND_COMMENTS);
	setRequestType(Query.PHOTO);

	super.onViewCreated(view, savedInstanceState);
	
	//Crash if before super.onViewCreated(view, savedInstanceState);
	getListView().getAdapter().registerDataSetObserver(observer);
}