2

I set a breakpoint at one of the lines but it seems that it never stops at the break point, and I assume based on that that it simply wasn't triggered, here is the code:

final ImageView imageViewRoomButton = (ImageView) findViewById(R.id.imageView9);

final GestureDetector gdt = new GestureDetector(new GestureListener());

imageViewRoomButton.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(final View view, final MotionEvent event) {
            gdt.onTouchEvent(event);
            return true;
        }
    });


private class GestureListener extends GestureDetector.SimpleOnGestureListener {

    @Override
    public boolean onDown(MotionEvent event) {



        return true;
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        Toast toast1 = Toast.makeText(getApplicationContext(), "you just swiped up", Toast.LENGTH_LONG);
        toast1.show();

        if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
            return true; // Right to left
        }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
            return true; // Left to right
        }

        if(e1.getY() - e2.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {


            return true; // Bottom to top
        }  else if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
            return true; // Top to bottom
        }
        return true;
    }
}

I placed breakpoints in both onFling, onDown and onTouch, nothing happens.

Any suggestions?

VictorCharlie23
  • 121
  • 1
  • 10
  • make sure you don't have any View above your imageViewRoomButton, and the view grope doesn't handle touch event !! – Anas Altair Sep 30 '17 at 10:04
  • @AnasAltair Now things are really complicated: 1. I do have a view above it, but I have an animation which sorta moves the imageViewRoomButton out of its way. Will that still be a problem? 2. Also, I don't know what view grope is, you mean view group??? What's a view group? Isn't a view completely ono its own? – VictorCharlie23 Sep 30 '17 at 11:06
  • when you touch screen, the first view handle touch event will obscure the rest views, 2 view grope which hold your view. – Anas Altair Oct 01 '17 at 14:48
  • Anyway to... deal with that? – VictorCharlie23 Oct 09 '17 at 00:56

0 Answers0