Exemplo n.º 1
0
 private void dispatchTouchEventToListView(MotionEvent event) {
   int motionX = (int) event.getX();
   DebugLog.d(TAG, "motionMove real motionX:" + motionX);
   if (event.getAction() == MotionEvent.ACTION_DOWN) {
     mTouchDownY = 0;
     mKeyguardListView.dealwithTouchEvent(event);
   }
   DebugLog.d(
       TAG,
       "motionMove real is beginScroll:" + mKeyguardListView.isBeginScroll((int) event.getX()));
   if (mKeyguardListView.isBeginScroll()) {
     if (event.getAction() != MotionEvent.ACTION_UP) {
       //                int infozoneHeight =
       // mKeyguardViewHost.getKeyguardPage().getInfozoneViewHeight();
       int infozoneHeight = 0;
       int copyWriter = mKeyguardViewHost.getHkCaptionsViewHeight();
       int scollAtHorizontalHeight =
           KWDataCache.getAllScreenHeigt(mContext) - infozoneHeight - copyWriter;
       DebugLog.d(TAG, "motionMove real mTouchDownY:" + mTouchDownY);
       DebugLog.d(TAG, "motionMove real scollAtHorizontalHeight:" + scollAtHorizontalHeight);
       if (mTouchDownY < scollAtHorizontalHeight) {
         mKeyguardListView.dealwithTouchEvent(event);
       }
     }
   }
   if (event.getAction() == MotionEvent.ACTION_UP) {
     mKeyguardListView.dealwithTouchEvent(event);
   }
 }
    @Override
    public boolean onFling(
        final MotionEvent pMotionEventStart,
        final MotionEvent pMotionEventEnd,
        final float pVelocityX,
        final float pVelocityY) {
      final float swipeMinDistance = this.mSwipeMinDistance;

      final boolean isHorizontalFling = Math.abs(pVelocityX) > Math.abs(pVelocityY);

      if (isHorizontalFling) {
        if (pMotionEventStart.getX() - pMotionEventEnd.getX() > swipeMinDistance) {
          return SurfaceGestureDetector.this.onSwipeLeft();
        } else if (pMotionEventEnd.getX() - pMotionEventStart.getX() > swipeMinDistance) {
          return SurfaceGestureDetector.this.onSwipeRight();
        }
      } else {
        if (pMotionEventStart.getY() - pMotionEventEnd.getY() > swipeMinDistance) {
          return SurfaceGestureDetector.this.onSwipeUp();
        } else if (pMotionEventEnd.getY() - pMotionEventStart.getY() > swipeMinDistance) {
          return SurfaceGestureDetector.this.onSwipeDown();
        }
      }

      return false;
    }
Exemplo n.º 3
0
  @Override
  public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {

    final int x1 = (int) e1.getX();
    final int y1 = (int) e1.getY();
    final int x2 = (int) e2.getX();
    final int y2 = (int) e2.getY();
    final int deltaX = x2 - mItemX;
    final int deltaY = y2 - mItemY;

    if (mCanDrag && !mDragging && (mHitPos != MISS || mFlingHitPos != MISS)) {
      if (mHitPos != MISS) {
        if (mDragInitMode == ON_DRAG && Math.abs(y2 - y1) > mTouchSlop && mSortEnabled) {
          startDrag(mHitPos, deltaX, deltaY);
        } else if (mDragInitMode != ON_DOWN && Math.abs(x2 - x1) > mTouchSlop && mRemoveEnabled) {
          mIsRemoving = true;
          startDrag(mFlingHitPos, deltaX, deltaY);
        }
      } else if (mFlingHitPos != MISS) {
        if (Math.abs(x2 - x1) > mTouchSlop && mRemoveEnabled) {
          mIsRemoving = true;
          startDrag(mFlingHitPos, deltaX, deltaY);
        } else if (Math.abs(y2 - y1) > mTouchSlop) {
          mCanDrag = false; // if started to scroll the list then
          // don't allow sorting nor fling-removing
        }
      }
    }
    // return whatever
    return false;
  }
Exemplo n.º 4
0
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       init_x = event.getX();
       return true;
     case MotionEvent.ACTION_UP:
       float distance = init_x - event.getX();
       if (distance > 80) {
         viewFlipper.showNext();
         activeWindow++;
       }
       if (distance < -80) {
         viewFlipper.showPrevious();
         activeWindow--;
       }
       if (activeWindow < 0) activeWindow = 4;
       if (activeWindow > 4) activeWindow = 0;
       startPanel = activeWindow;
       updateTitleView();
     default:
       break;
   }
   return false;
 }
 @Override
 public boolean onTouchEvent(MotionEvent motionEvent) {
   switch (motionEvent.getAction()) {
     case MotionEvent.ACTION_DOWN:
       currentDrawingPath = new DrawingPath();
       currentDrawingPath.paint = currentPaint;
       currentDrawingPath.path = new Path();
       currentDrawingPath.path.moveTo(motionEvent.getX(), motionEvent.getY());
       currentDrawingPath.path.lineTo(motionEvent.getX(), motionEvent.getY());
       break;
     case MotionEvent.ACTION_MOVE:
       currentDrawingPath.path.lineTo(motionEvent.getX(), motionEvent.getY());
       break;
     case MotionEvent.ACTION_UP:
       currentDrawingPath.path.lineTo(motionEvent.getX(), motionEvent.getY());
       paths.add(currentDrawingPath);
       currentDrawingPath = null;
       break;
       //                final int historySize = ev.getHistorySize();
       //                final int pointerCount = ev.getPointerCount();
       //                for (int h = 0; h < historySize; h++) {
       //                	for (int p = 0; p < pointerCount; p++) {
       //                		points.add(new PointF(ev.getHistoricalX(p, h), ev.getHistoricalY(p,
       // h)));
       //            		}
       //                }
       //                for (int p = 0; p < pointerCount; p++) {
       //                	points.add(new PointF(ev.getX(p), ev.getY(p)));
       //                }
   }
   invalidate();
   return true;
 }
Exemplo n.º 6
0
  @Override
  public boolean onInterceptTouchEvent(MotionEvent ev) {
    Log.e("mcoy", "McoyScrollView--onInterceptTouchEvent");
    switch (ev.getAction()) {
      case MotionEvent.ACTION_DOWN:
        xDistance = yDistance = 0f;
        xLast = ev.getX();
        yLast = ev.getY();
        break;
      case MotionEvent.ACTION_MOVE:
        final float curX = ev.getX();
        final float curY = ev.getY();

        xDistance += Math.abs(curX - xLast);
        yDistance += Math.abs(curY - yLast);
        xLast = curX;
        yLast = curY;

        if (xDistance > yDistance) {
          return false;
        }
    }
    boolean onIntercept = super.onInterceptTouchEvent(ev);
    Log.e("mcoy", "McoyScrollView--onInterceptTouchEvent return " + onIntercept);

    return onIntercept;
  }
Exemplo n.º 7
0
  @Override
  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    /*boolean res = super.onFling(e1, e2, velocityX, velocityY);
    Log.i("OF","onFLing" + res);
    return res;*/

    final float xDistance = Math.abs(e1.getX() - e2.getX());
    final float yDistance = Math.abs(e1.getY() - e2.getY());

    if (xDistance > OFGestureListener.swipe_Max_Distance
        || yDistance > OFGestureListener.swipe_Max_Distance) return false;

    velocityX = Math.abs(velocityX);
    velocityY = Math.abs(velocityY);
    boolean result = false;

    if (velocityX > OFGestureListener.swipe_Min_Velocity
        && xDistance > OFGestureListener.swipe_Min_Distance) {
      if (e1.getX() > e2.getX()) // right to left
      OFAndroid.onSwipe(e1.getPointerId(0), SWIPE_LEFT);
      else OFAndroid.onSwipe(e1.getPointerId(0), SWIPE_RIGHT);

      result = true;
    } else if (velocityY > OFGestureListener.swipe_Min_Velocity
        && yDistance > OFGestureListener.swipe_Min_Distance) {
      if (e1.getY() > e2.getY()) // bottom to up
      OFAndroid.onSwipe(e1.getPointerId(0), SWIPE_UP);
      else OFAndroid.onSwipe(e1.getPointerId(0), SWIPE_DOWN);

      result = true;
    }

    return result;
  }
Exemplo n.º 8
0
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   int ex = (int) event.getX();
   int ey = (int) event.getY();
   System.out.println(event.getX() + "," + event.getY());
   int selectIndex = -1;
   for (int i = 0; i < menuItems.length; i++) {
     System.out.println(x + "  " + (y + i * 43));
     if (Poke.inRect(ex, ey, x, y + i * 43, 125, 33)) {
       selectIndex = i;
       break;
     }
   }
   System.out.println(selectIndex);
   switch (selectIndex) {
     case 0:
       ddz.handler.sendEmptyMessage(DDZ.GAME);
       break;
     case 1:
       break;
     case 2:
       break;
     case 3:
       break;
     case 4:
       ddz.finish();
       break;
   }
   return super.onTouchEvent(event);
 }
  @Override
  public boolean onSingleTapConfirmed(MotionEvent e) {
    if (this.photoViewAttacher == null) return false;

    ImageView imageView = photoViewAttacher.getImageView();

    if (null != photoViewAttacher.getOnPhotoTapListener()) {
      final RectF displayRect = photoViewAttacher.getDisplayRect();

      if (null != displayRect) {
        final float x = e.getX(), y = e.getY();

        // Check to see if the user tapped on the photo
        if (displayRect.contains(x, y)) {

          float xResult = (x - displayRect.left) / displayRect.width();
          float yResult = (y - displayRect.top) / displayRect.height();

          photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult);
          return true;
        }
      }
    }
    if (null != photoViewAttacher.getOnViewTapListener()) {
      photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY());
    }

    return false;
  }
Exemplo n.º 10
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {

    // If this View is not enabled, don't allow for touch interactions.
    if (!isEnabled()) {
      return false;
    }

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        onActionDown(event.getX(), event.getY());
        return true;

      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_CANCEL:
        this.getParent().requestDisallowInterceptTouchEvent(false);
        onActionUp(event.getX(), event.getY());
        return true;

      case MotionEvent.ACTION_MOVE:
        onActionMove(event.getX());
        this.getParent().requestDisallowInterceptTouchEvent(true);
        return true;

      default:
        return false;
    }
  }
  private void setContext(MotionEvent curr) {
    if (mCurrEvent != null) {
      mCurrEvent.recycle();
    }
    mCurrEvent = MotionEvent.obtain(curr);

    mCurrLen = -1;
    mPrevLen = -1;
    mScaleFactor = -1;

    final MotionEvent prev = mPrevEvent;

    final float px0 = prev.getX(0);
    final float py0 = prev.getY(0);
    final float px1 = prev.getX(1);
    final float py1 = prev.getY(1);
    final float cx0 = curr.getX(0);
    final float cy0 = curr.getY(0);
    final float cx1 = curr.getX(1);
    final float cy1 = curr.getY(1);

    final float pvx = px1 - px0;
    final float pvy = py1 - py0;
    final float cvx = cx1 - cx0;
    final float cvy = cy1 - cy0;
    mPrevFingerDiffX = pvx;
    mPrevFingerDiffY = pvy;
    mCurrFingerDiffX = cvx;
    mCurrFingerDiffY = cvy;

    mTimeDelta = curr.getEventTime() - prev.getEventTime();
    mCurrPressure = curr.getPressure(0) + curr.getPressure(1);
    mPrevPressure = prev.getPressure(0) + prev.getPressure(1);
  }
Exemplo n.º 12
0
  public boolean onTouchDown(MotionEvent touch) {
    int action = touch.getAction();
    int x = 0;
    int y = 0;
    switch (action & MotionEvent.ACTION_MASK) {
      case MotionEvent.ACTION_DOWN:
        y = (int) touch.getY();
        x = (int) touch.getX();

        int col = x / tileSize;
        int row = y / tileSize;
        board.changeTileState(row, col);
        isOnClick = true;
        break;

        // DOES NOT DETECT MOTION... ONLY TOUCH DOWN
      case MotionEvent.ACTION_MOVE:
        if (isOnClick
            && (Math.abs(x - touch.getX()) > SCROLL_THRESHOLD
                || Math.abs(y - touch.getY()) > SCROLL_THRESHOLD)) {
          // System.out.println("movement detected");
          isOnClick = false;
        }
        break;
    }
    return true;
  }
    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {

      if (distanceY != 0 && distanceX != 0) {}

      if (null != bannerView) {
        Rect rect = new Rect();
        bannerView.getHitRect(rect);

        if (null != e1) {
          if (rect.contains((int) e1.getX(), (int) e1.getY())) {
            return false;
          }
        }

        if (null != e2) {
          if (rect.contains((int) e2.getX(), (int) e2.getY())) {
            return false;
          }
        }
      }
      //            if(Math.abs(distanceY) >= Math.abs(distanceX))
      //            {
      //                Log.e("listview", "********************** distanceX :" + distanceX + "
      // distanceY" + distanceY + "\n");
      //                return true;
      //            }
      //            Log.e("listview", "-------------------------- distanceX :" + distanceX + "
      // distanceY" + distanceY + "\n");
      return true;
    }
        @Override
        public boolean onTouch(View v, MotionEvent event) {
          switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
              matrix.getValues(imageValues);

              selectedPoint[0] = (event.getX() - imageValues[2]) / imageValues[0];
              selectedPoint[1] = (event.getY() - imageValues[5]) / imageValues[4];

              Log.d("POINT_TOUCH", "IMAGE : " + selectedPoint[0] + " and " + selectedPoint[1]);

              if (selectedPoint[1] < bounds.height()) {
                marker.setX(event.getX() - markerBounds.width() / 2);
                marker.setY(event.getY() - markerBounds.height());
                marker.setAlpha(VISIBLE);
                measureButton.setClickable(true);
                measureButton.setEnabled(true);
              } else {
                marker.setAlpha(TRANSPARENT);
                measureButton.setClickable(false);
                measureButton.setEnabled(false);
              }
              break;
          }
          return true;
        }
Exemplo n.º 15
0
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       touchX = event.getX();
       touchY = event.getY();
       return true;
     case MotionEvent.ACTION_UP:
       float slop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
       if (Math.abs(event.getX() - touchX) < slop && Math.abs(event.getY() - touchY) < slop) {
         int offsetLeft = (getWidth() - countInRow * smileySize) / 2;
         if (touchX > offsetLeft || touchX < offsetLeft + smileySize * countInRow) {
           int row = (int) (touchY / smileySize);
           int col = (int) ((touchX - offsetLeft) / smileySize);
           int index = row * countInRow + col;
           if (index >= 0 && index < smileyIds.length) {
             if (onSmileClickedListener != null) {
               playSoundEffect(SoundEffectConstants.CLICK);
               onSmileClickedListener.onSmileClicked(smileyIds[index]);
             }
           }
         }
       }
       return true;
   }
   return false;
 }
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
      switch (ev.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
          if (DEBUG_EDGE_SWIPE) Log.d(TAG, "action down " + ev.getY());
          mFirstX = ev.getX();
          mFirstY = ev.getY();
          mConsuming = false;
          break;

        case MotionEvent.ACTION_MOVE:
          if (DEBUG_EDGE_SWIPE) Log.d(TAG, "action move " + ev.getY());
          final float dY = ev.getY() - mFirstY;
          final float daX = Math.abs(ev.getX() - mFirstX);
          final float daY = Math.abs(dY);
          if (!mConsuming && daX < daY && daY > mTouchSlop) {
            snooze();
            if (dY > 0) {
              if (DEBUG_EDGE_SWIPE) Log.d(TAG, "found an open");
              mBar.animateExpandNotificationsPanel();
            }
            mConsuming = true;
          }
          break;

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
          if (DEBUG_EDGE_SWIPE) Log.d(TAG, "action done");
          mConsuming = false;
          break;
      }
      return mConsuming;
    }
Exemplo n.º 17
0
  @Override
  public boolean onTouch(View view, MotionEvent motionEvent) {
    x = motionEvent.getX();
    y = motionEvent.getY();
    try {
      Thread.sleep(50);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    switch (motionEvent.getAction()) {
      case MotionEvent.ACTION_DOWN:
        sX = motionEvent.getX();
        sY = motionEvent.getY();
        dX = 0;
        dY = 0;
        aniX = 0;
        aniY = 0;
        scaledX = 0;
        scaledY = 0;
        fX = 0;
        fY = 0;
        break;
      case MotionEvent.ACTION_UP:
        fX = motionEvent.getX();
        fY = motionEvent.getY();
        dX = fX - sX;
        dY = fY - sY;
        scaledX = dX / 30;
        scaledY = dY / 30;
        x = y = 0;
        break;
    }

    return true;
  }
Exemplo n.º 18
0
 public boolean onDoubleTap(MotionEvent event) {
   if (bottomView != null) {
     bottomView.setVisibility(View.GONE);
   }
   final float currentScale = getCurrentScale();
   final float baseScale = getScale(baseMatrix);
   if (roughCompareScale(baseScale, currentScale)) { // 缩放率差距降噪,认为相等(处在初始状态)
     float targetScale =
         Math.min(currentScale * 2, MAX_SCALE_RATE); // 放大为当前缩放率的2倍但是不能超过最大缩放率
     float deltaScale = targetScale / currentScale;
     final Matrix tmpMatrix = new Matrix(currentMatrix);
     tmpMatrix.postScale(deltaScale, deltaScale, event.getX(), event.getY());
     float destX = (getWidth() - getScaleWidth(tmpMatrix)) / 2;
     float destY = (getHeight() - getScaleHeight(tmpMatrix)) / 2;
     AnimZoomTo(targetScale, event.getX(), event.getY(), destX, destY, 300);
     return true;
   }
   if (currentScale > getScale(baseMatrix)) { // 放大状态,双击变成初始状态
     AnimZoomTo(
         getScale(baseMatrix),
         event.getX(),
         event.getY(),
         getTransX(baseMatrix),
         getTransY(baseMatrix),
         300);
     return true;
   }
   return true;
 };
Exemplo n.º 19
0
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   final int action = event.getActionMasked();
   switch (action) {
     case MotionEvent.ACTION_DOWN:
       downX = event.getX();
       downY = event.getY();
       break;
     case MotionEvent.ACTION_UP:
       // 先判断是否是点击事件
       if ((isClickable() || isLongClickable())
           && ((event.getX() - downX) < mTouchSlop || (event.getY() - downY) < mTouchSlop)) {
         // 这里我们得到了一个点击事件
         if (isFocusable() && isFocusableInTouchMode() && !isFocused()) requestFocus();
         if (event.getEventTime() - event.getDownTime() >= ViewConfiguration.getLongPressTimeout()
             && isLongClickable()) {
           // 是一个长按事件
           //                        performLongClick();
           Log.i("actiontype", "longClick");
         } else {
           // 点击事件
           performClick(event.getX());
         }
       }
       break;
   }
   return true;
 }
Exemplo n.º 20
0
  // Touch events
  @Override
  public boolean onTouch(View v, MotionEvent event) {
    final int touchDevId = event.getDeviceId();
    final int pointerCount = event.getPointerCount();
    // touchId, pointerId, action, x, y, pressure
    int actionPointerIndex =
        (event.getAction() & MotionEvent.ACTION_POINTER_ID_MASK)
            >> MotionEvent.ACTION_POINTER_ID_SHIFT; /* API 8: event.getActionIndex(); */
    int pointerFingerId = event.getPointerId(actionPointerIndex);
    int action =
        (event.getAction() & MotionEvent.ACTION_MASK); /* API 8: event.getActionMasked(); */

    float x = event.getX(actionPointerIndex) / mWidth;
    float y = event.getY(actionPointerIndex) / mHeight;
    float p = event.getPressure(actionPointerIndex);

    if (action == MotionEvent.ACTION_MOVE && pointerCount > 1) {
      // TODO send motion to every pointer if its position has
      // changed since prev event.
      for (int i = 0; i < pointerCount; i++) {
        pointerFingerId = event.getPointerId(i);
        x = event.getX(i) / mWidth;
        y = event.getY(i) / mHeight;
        p = event.getPressure(i);
        SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
      }
    } else {
      SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p);
    }
    return true;
  }
Exemplo n.º 21
0
 public boolean onTouch(View v, MotionEvent event) {
   // TODO Auto-generated method stub
   switch (event.getAction()) {
     case MotionEvent.ACTION_MOVE:
       nowX = event.getX();
       break;
     case MotionEvent.ACTION_DOWN:
       if (event.getX() > bg_on.getWidth() || event.getY() > bg_on.getHeight()) {
         return false;
       }
       onSlip = true;
       downX = event.getX();
       nowX = downX;
       break;
     case MotionEvent.ACTION_UP:
       onSlip = false;
       boolean lastChoose = nowChoose;
       if (event.getX() >= (bg_on.getWidth() / 2)) {
         nowChoose = true;
       } else {
         nowChoose = false;
       }
       if (isChgLsnOn && (lastChoose != nowChoose)) {
         ChgLsn.OnChanged(nowChoose);
       }
       break;
     default:
       break;
   }
   invalidate();
   return true;
 }
Exemplo n.º 22
0
  /* (non-Javadoc)
   * @see com.google.android.maps.MapView#onTouchEvent(android.view.MotionEvent)
   */
  @Override
  public boolean onTouchEvent(MotionEvent ev) {

    int action = ev.getAction();
    int t;

    switch (action) {
      case MotionEvent.ACTION_DOWN:
        clicked = true;
        break;

      case MotionEvent.ACTION_MOVE:
        clicked = false;
        t = ev.getHistorySize();
        geoPoint = getProjection().fromPixels((int) ev.getX(t), (int) ev.getY(t));
        break;

      case MotionEvent.ACTION_UP:
        if (clicked) {
          t = ev.getHistorySize();
          geoPoint = getProjection().fromPixels((int) ev.getX(t), (int) ev.getY(t));
          getController().animateTo(geoPoint);
          invalidate();
          // getPositionBtn.setEnabled(true);
        }
        break;
    }

    // TODO Auto-generated method stub
    return super.onTouchEvent(ev);
  }
Exemplo n.º 23
0
 @Override
 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
   boolean result = false;
   try {
     float diffY = e2.getY() - e1.getY();
     float diffX = e2.getX() - e1.getX();
     if (Math.abs(diffX) > Math.abs(diffY)) {
       if (Math.abs(diffX) > SWIPE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
         if (diffX > 0) {
           onSwipeRight();
         } else {
           onSwipeLeft();
         }
       }
     } else {
       if (Math.abs(diffY) > SWIPE_THRESHOLD && Math.abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) {
         if (diffY > 0) {
           onSwipeBottom();
         } else {
           onSwipeTop();
         }
       }
     }
   } catch (Exception exception) {
     exception.printStackTrace();
   }
   return result;
 }
Exemplo n.º 24
0
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
      if (!isRotating) {
        return false;
      }
      // get the quadrant of the start and the end of the fling
      int q1 =
          getQuadrant(e1.getX() - (circleWidth / 2), circleHeight - e1.getY() - (circleHeight / 2));
      int q2 =
          getQuadrant(e2.getX() - (circleWidth / 2), circleHeight - e2.getY() - (circleHeight / 2));

      // the inversed rotations
      if ((q1 == 2 && q2 == 2 && Math.abs(velocityX) < Math.abs(velocityY))
          || (q1 == 3 && q2 == 3)
          || (q1 == 1 && q2 == 3)
          || (q1 == 4 && q2 == 4 && Math.abs(velocityX) > Math.abs(velocityY))
          || ((q1 == 2 && q2 == 3) || (q1 == 3 && q2 == 2))
          || ((q1 == 3 && q2 == 4) || (q1 == 4 && q2 == 3))
          || (q1 == 2 && q2 == 4 && quadrantTouched[3])
          || (q1 == 4 && q2 == 2 && quadrantTouched[3])) {

        CircleLayout.this.post(new FlingRunnable(-1 * (velocityX + velocityY)));
      } else {
        // the normal rotation
        CircleLayout.this.post(new FlingRunnable(velocityX + velocityY));
      }

      return true;
    }
  /** 实现左右滑动切换校区 */
  @Override
  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    float zoom = 17;
    if (e1.getX() - e2.getX() > 100) {
      if (flag < position_schoolLatLngs.length - 1) {
        flag++;
      } else {
        flag = 0;
      }
      this.flipper.setInAnimation(
          AnimationUtils.loadAnimation(this.getActivity(), R.anim.push_left_in));
      this.flipper.setOutAnimation(
          AnimationUtils.loadAnimation(this.getActivity(), R.anim.push_left_out));
    } else if (e1.getX() - e2.getX() < -100) {
      if (flag > 0) {
        flag--;
      } else {
        flag = position_schoolLatLngs.length - 1;
      }
      this.flipper.setInAnimation(
          AnimationUtils.loadAnimation(this.getActivity(), R.anim.push_right_in));
      this.flipper.setOutAnimation(
          AnimationUtils.loadAnimation(this.getActivity(), R.anim.push_right_out));
    }
    mMap.clear();
    loadMap(flag + 2, true);
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(position_schoolLatLngs[flag], zoom));
    this.flipper.setDisplayedChild(flag);

    return false;
  }
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   int x = (int) event.getX();
   int y = (int) event.getY();
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       lastX = (int) event.getX();
       lastY = (int) event.getY();
       break;
     case MotionEvent.ACTION_MOVE:
       int offsetX = x - lastX;
       int offsetY = y - lastY;
       ((View) getParent()).scrollBy(-offsetX, -offsetY);
       break;
     case MotionEvent.ACTION_UP:
       // 手指离开时,执行滑动过程
       View viewGroup = ((View) getParent());
       ScrollerHelper.getScroller()
           .startScroll(
               viewGroup.getScrollX(),
               viewGroup.getScrollY(),
               -viewGroup.getScrollX(),
               -viewGroup.getScrollY());
       invalidate();
       break;
   }
   return true;
 }
Exemplo n.º 27
0
  /** 对拖拽图片不同的点击事件处理 */
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    int X = (int) event.getX();

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        dragBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.lock_touch);
        heartView.setImageBitmap(dragBitmap);
        linearLayoutL.setBackgroundResource(R.drawable.left_bg_default);
        linearLayoutR.setBackgroundResource(R.drawable.left_bg_default);
        locationX = (int) event.getX();
        Log.i(TAG, "是否点击到位=" + isActionDown(event));
        return isActionDown(event); // 判断是否点击了滑动区�?

      case MotionEvent.ACTION_MOVE: // 保存x轴方向,绘制图画
        locationX = X;
        invalidate(); // 重新绘图
        return true;

      case MotionEvent.ACTION_UP: // 判断是否解锁成功
        dragBitmap =
            BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_slide_circle_n);
        heartView.setImageBitmap(dragBitmap);
        linearLayoutL.setBackgroundColor(getResources().getColor(R.color.transparent));
        linearLayoutR.setBackgroundResource(getResources().getColor(R.color.transparent));
        if (!unLockLeft() && !unLockRight()) { // 没有解锁成功,动画应该回滚
          flag = false;
          handleActionUpEvent(event); // 动画回滚
        }
        return true;
    }
    return super.onTouchEvent(event);
  }
Exemplo n.º 28
0
  @Override
  public boolean dispatchTouchEvent(MotionEvent event) {
    // BUG #57535
    // 【发帖】发帖页面键盘弹出后,如果这时点击手机的HOME键、电源键或其他输入键盘上手机自带按钮进入其他页面,再返回到发帖页面,输入键盘会隐藏,小键盘按钮会高亮显示
    if (isOpenComment) {
      if (event.getAction() == MotionEvent.ACTION_DOWN) {
        int[] l = {0, 0};
        mEditContent.getLocationInWindow(l);
        int left = l[0], top = l[1];
        int bottom = top + mEditContent.getHeight(), right = left + mEditContent.getWidth();
        System.out.println(
            "left:" + left + "; top:" + top + ";bottom:" + bottom + ";right:" + right);
        if (event.getX() > left
            && event.getX() < right
            && event.getY() > top
            && event.getY() < bottom) {
          mInputBar.showCommonInputBar();
          // return false;
        } else {
          InputMethodUtils.collapseSoftInputMethod(mContext, mEditContent.getWindowToken());
          // return true;
        }
      }
    }

    return super.dispatchTouchEvent(event);
  }
Exemplo n.º 29
0
 public boolean onTouchEvent(MotionEvent paramMotionEvent) {
   if ((!this.mInTouchMode) && (paramMotionEvent.getAction() != 0)) ;
   do {
     do {
       do {
         return true;
         switch (paramMotionEvent.getAction()) {
           default:
             return true;
           case 0:
             this.mLastMotionX = paramMotionEvent.getX();
             this.mLastMotionY = paramMotionEvent.getY();
             this.mInTouchMode = true;
             this.mSelectedIndex = getSelectedIndex();
             invalidate();
             return true;
           case 2:
             this.mLastMotionX = paramMotionEvent.getX();
             this.mLastMotionY = paramMotionEvent.getY();
           case 3:
           case 1:
         }
       } while (getSelectedIndex() == this.mSelectedIndex);
       this.mSelectedIndex = -1;
       this.mInTouchMode = false;
     } while (!isItemPressed());
     invalidate();
     return true;
     this.mSelectedIndex = -1;
   } while (!isItemPressed());
   invalidate();
   return true;
   doClickEvent();
   return true;
 }
Exemplo n.º 30
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    int pointerCount = event.getPointerCount();

    if (event.getAction() != MotionEvent.ACTION_UP) {
      if (pointerCount == 1) {
        pointerText1.setText("(" + event.getX(0) + "," + event.getY(0) + ")");
        pointerText2.setText("");

      } else if (pointerCount == 2) {
        pointerText1.setText("");
        pointerText2.setText(
            "("
                + event.getX(0)
                + ","
                + event.getY(0)
                + ")-("
                + event.getX(1)
                + ","
                + event.getY(1)
                + ")");
      }
    }

    return super.onTouchEvent(event);
  }