@Override
  public boolean onTouchEvent(MotionEvent event) {

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
      // super.onInterceptTouchEvent(event);

      float endX = event.getX();
      float endY = event.getY();
      if (isAClick(startX, endX, startY, endY)) {
        if (mOnItemClickListener != null) {
          mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());
        }
        // launchFullPhotoActivity(imageUrls);// WE HAVE A CLICK!!
      } else {
        super.onTouchEvent(event);
      }
    }

    if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
      startX = event.getX();
      startY = event.getY();
    }

    /*if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP)
    {
        super.onTouchEvent(event);
    }*/

    float[] difference = handleMotionEvent(event);

    if (mCurrentView.pagerCanScroll()) {
      return super.onTouchEvent(event);
    } else {
      if (difference != null && mCurrentView.onRightSide && difference[0] < 0) // move right
      {
        return super.onTouchEvent(event);
      }
      if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) // move left
      {
        return super.onTouchEvent(event);
      }
      if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
        return super.onTouchEvent(event);
      }
    }

    return false;
  }
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    try {

      if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
        // super.onInterceptTouchEvent(event);

        float endX = event.getX();
        float endY = event.getY();
        if (isAClick(startX, endX, startY, endY)) {
          if (mOnItemClickListener != null) {
            mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem());
          }
        } else {
          super.onTouchEvent(event);
        }
      }

      if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        startX = event.getX();
        startY = event.getY();
      }

      float[] difference = handleMotionEvent(event);

      if (mCurrentView.pagerCanScroll()) {
        return super.onTouchEvent(event);
      } else {
        if (difference != null && mCurrentView.onRightSide && difference[0] < 0) // move right
        {
          return super.onTouchEvent(event);
        }
        if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) // move left
        {
          return super.onTouchEvent(event);
        }
        if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) {
          return super.onTouchEvent(event);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return false;
  }