コード例 #1
0
ファイル: ResizeManager.java プロジェクト: TinyNiko/AManager
  public boolean onTouchEvent(@NonNull MotionEvent event) {
    final int action = MotionEventCompat.getActionMasked(event);
    if (action == MotionEvent.ACTION_MOVE) {
      mVelocityTracker.addMovement(event);
    }
    if (mState == State.DRAGGING) {
      switch (action) {
        case MotionEvent.ACTION_MOVE:
          int deltaY = calculateDistanceForDrag(event);
          mProgressManager.applyDelta(deltaY);
          break;
        case MotionEvent.ACTION_UP:
          finishMotionEvent();
          if (type == LEFT) {
            mCalendarView.prev();
          } else if (type == RIGHT) {
            mCalendarView.next();
          }
          break;
      }

    } else if (action == MotionEvent.ACTION_MOVE) {
      checkForResizing(event);
    } else if (action == MotionEvent.ACTION_UP) {
      if (type == LEFT) {
        mCalendarView.prev();
      } else if (type == RIGHT) {
        mCalendarView.next();
      }
    }

    return true;
  }
コード例 #2
0
ファイル: ResizeManager.java プロジェクト: TinyNiko/AManager
 public boolean onInterceptTouchEvent(@NonNull MotionEvent ev) {
   final int action = MotionEventCompat.getActionMasked(ev);
   switch (action) {
     case MotionEvent.ACTION_DOWN:
       type = -1;
       return onDownEvent(ev);
     case MotionEvent.ACTION_MOVE:
       mVelocityTracker.addMovement(ev);
       return checkForResizing(ev);
     case MotionEvent.ACTION_UP:
       finishMotionEvent();
       if (type == LEFT) {
         mCalendarView.prev();
       } else if (type == RIGHT) {
         mCalendarView.next();
       }
       return false;
   }
   return false;
 }