When I use the pinch zoom gesture, in a horizontal way, the swipe function is always called when it reached a certain difference of the pressed coordinates and the released coordinates.

How can I fix this?

This are the settings for the webview

    view.getSettings().setBuiltInZoomControls(true);
    view.getSettings().setSupportZoom(true); 
    view.getSettings().setDisplayZoomControls(false);

The swipe function

    protected void swipePage(View v, MotionEvent event, int book) {
    int action = MotionEventCompat.getActionMasked(event);

    switch (action) {
    case (MotionEvent.ACTION_DOWN):
        swipeOriginX = event.getX();
        swipeOriginY = event.getY();
        break;

    case (MotionEvent.ACTION_UP):
        int quarterWidth = (int) (screenWidth * 0.3);
        float diffX = swipeOriginX - event.getX();
        float diffY = swipeOriginY - event.getY();
        float absDiffX = Math.abs(diffX);
        float absDiffY = Math.abs(diffY);

        if ((diffX > quarterWidth) && (absDiffX > absDiffY)) {
            x = 1;
            try {
                navigator.goToNextChapter(index);
                x = 0;
            } catch (Exception e) {
                x = 1;
                errorMessage(getString(R.string.error_cannotTurnPage));
            }
        } else if ((diffX < -quarterWidth) && (absDiffX > absDiffY)) {
            x = 1;
            try {
                navigator.goToPrevChapter(index);
                x = 0;
            } catch (Exception e) {
                x = 1;
                errorMessage(getString(R.string.error_cannotTurnPage));
            }
        }
        break;
    }
}

Related posts

Recent Viewed