Reputation: 43
I have zoomable image and I'm using ScaleGestureDetector.SimpleOnScaleGestureListener
. I need to implement following items:
I have some issue. Before Double Tap always is Single Tap and picture is zooming, but appear Toast. Is there any way to avoid Single Tap? I dont have enough savvy to solve this problem.
P.S. I can't use OnDoubleTapListener
because use ScaleGestureDetector.SimpleOnScaleGestureListener
.
UPD
case MotionEvent.ACTION_UP:
firstTime = System.currentTimeMillis();
if (Math.abs(firstTime-secondTime) < 300L) {
// scale my matrix
---//---
DONE = true; //this flag symbolize, that toast doesn't appear (false - appears)
}
else if (!DONE) {
// making toast
}
secondTime = firstTime;
break;
When DoubleTap is enable image scaled but appears toast
Upvotes: 1
Views: 445
Reputation: 43
@matt5784, thank you. I was able to solve my problem.
case MotionEvent.ACTION_UP:
float xDiff = Math.abs(curr.x - start.x);
float yDiff = Math.abs(curr.y - start.y);
firstTime = System.currentTimeMillis();
if (Math.abs(firstTime-secondTime) > 200L) {
myHand.postDelayed(mRun, 200);
}
else if (!DONE) {
//scale my matrix
DONE = true; //this flag symbolize, that toast doesn't appear (false - appears)
}
secondTime = firstTime;
break;
Handler myHand = new Handler();
private Runnable mRun = new Runnable() {
@Override
public void run() {
if (!DONE) {
// make toast
}
}
Upvotes: 2
Reputation: 3085
I would suggest implementing a delay where the information doesn't pop up immediately on a single tap, but only is displayed if it doesn't encounter a second tap within a reasonable amount of time (probably whatever your threshold for double-taps is). I.e. if it is set up to register any taps within .2 seconds as a double tap, don't display the info until you have waited .2 secs and are sure there isn't a double tap.
Alternate solution (probably less useful) - have the double tap/zoom function call whatever function makes the information box disappear. However it will probably still pop up for a very short amount of time which may look silly/be problematic.
Upvotes: 0