Skip to content
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

Updated ZoomageView: To add new on doubleclicklistener #101

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
30 changes: 30 additions & 0 deletions zoomage/src/main/java/com/jsibbold/zoomage/ZoomageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public class ZoomageView extends AppCompatImageView implements OnScaleGestureLis
private boolean doubleTapDetected = false;
private boolean singleTapDetected = false;

//listener
private onZoomageViewDoubleClickListener doubleClickListener;

public ZoomageView(Context context) {
super(context);
init(context, null);
Expand Down Expand Up @@ -387,6 +390,15 @@ public void setImageBitmap(Bitmap bm) {
setScaleType(startScaleType);
}

/**
* the zoomage double click listener
*
* @param doubleClickListener The double click listener
*/
public void setOnDoubleClickListener(onZoomageViewDoubleClickListener doubleClickListener){
this.doubleClickListener = doubleClickListener;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -477,7 +489,16 @@ public boolean onTouchEvent(MotionEvent event) {
zoomMatrix.postScale(doubleTapToZoomScaleFactor, doubleTapToZoomScaleFactor, scaleDetector.getFocusX(), scaleDetector.getFocusY());
animateScaleAndTranslationToMatrix(zoomMatrix, RESET_DURATION);
}
//notify onclick listeners
doubleClickListener.onDoubleClick(doubleTapToZoom);
//rest double Tap detected
doubleTapDetected = false;
return true;
}else if (!doubleTapToZoom && doubleTapDetected) {
//notify onclick listeners
doubleClickListener.onDoubleClick(doubleTapToZoom);
//rest double Tap detected
doubleTapDetected = false;
} else if (!singleTapDetected) {
/* if the event is a down touch, or if the number of touch points changed,
* we should reset our start point, as event origins have likely shifted to a
Expand Down Expand Up @@ -915,4 +936,13 @@ public void onAnimationCancel(Animator animation) {
public void onAnimationRepeat(Animator animation) {
}
}

public interface onZoomageViewDoubleClickListener{
/**
* Called on double click.
*
* @param isDoubleTapToZoom Indicates if double tap was made as zoom action
*/
public void onDoubleClick(boolean isDoubleTapToZoom);
}
}