コード例 #1
0
  /**
   * Handles Touch event
   *
   * @param event the motion event
   * @return
   */
  public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        lastTouchedPosition = getMotionEventPosition(event);
        scroller.forceFinished(true);
        clearMessages();
        listener.onTouch();
        break;

      case MotionEvent.ACTION_UP:
        if (scroller.isFinished()) listener.onTouchUp();
        break;

      case MotionEvent.ACTION_MOVE:
        // perform scrolling
        int distance = (int) (getMotionEventPosition(event) - lastTouchedPosition);
        if (distance != 0) {
          startScrolling();
          listener.onScroll(distance);
          lastTouchedPosition = getMotionEventPosition(event);
        }
        break;
    }

    if (!gestureDetector.onTouchEvent(event) && event.getAction() == MotionEvent.ACTION_UP) {
      justify();
    }

    return true;
  }
コード例 #2
0
 /**
  * Set next message to queue. Clears queue before.
  *
  * @param message the message to set
  */
 private void setNextMessage(int message) {
   clearMessages();
   animationHandler.sendEmptyMessage(message);
 }