Skip to content

OnScale listener #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
OnScale listener
  • Loading branch information
Macarse committed Mar 18, 2013
commit 80050e2b93f118db5ec420d479170bb354fcee2b
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ImageViewTouch extends ImageViewTouchBase {
protected boolean mScrollEnabled = true;
private OnImageViewTouchDoubleTapListener mDoubleTapListener;
private OnImageViewTouchSingleTapListener mSingleTapListener;
private OnImageViewTouchScaleListener mUserScaleListener;

public ImageViewTouch ( Context context, AttributeSet attrs ) {
super( context, attrs );
Expand All @@ -55,6 +56,10 @@ public void setSingleTapListener( OnImageViewTouchSingleTapListener listener ) {
mSingleTapListener = listener;
}

public void setUserScaleListener( OnImageViewTouchScaleListener listener ) {
mUserScaleListener = listener;
}

public void setDoubleTapEnabled( boolean value ) {
mDoubleTapEnabled = value;
}
Expand Down Expand Up @@ -254,6 +259,11 @@ public boolean onScale( ScaleGestureDetector detector ) {
float targetScale = getScale() * detector.getScaleFactor();

if ( mScaleEnabled ) {

if (mUserScaleListener != null) {
mUserScaleListener.onScale();
}

if( mScaled && span != 0 ) {
targetScale = Math.min( getMaxScale(), Math.max( targetScale, getMinScale() - 0.1f ) );
zoomTo( targetScale, detector.getFocusX(), detector.getFocusY() );
Expand All @@ -279,4 +289,9 @@ public interface OnImageViewTouchSingleTapListener {

void onSingleTapConfirmed();
}

public interface OnImageViewTouchScaleListener {
void onScale();
}

}