当前位置: 首页>>代码示例>>Java>>正文


Java MotionEvent.getPointerCount方法代码示例

本文整理汇总了Java中android.view.MotionEvent.getPointerCount方法的典型用法代码示例。如果您正苦于以下问题:Java MotionEvent.getPointerCount方法的具体用法?Java MotionEvent.getPointerCount怎么用?Java MotionEvent.getPointerCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.MotionEvent的用法示例。


在下文中一共展示了MotionEvent.getPointerCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: move

import android.view.MotionEvent; //导入方法依赖的package包/类
private synchronized void move(MotionEvent event) {
    for (PinData item : pressedRects) {
        boolean pressed = false;
        for (int i = 0; i < (event.getPointerCount() > maxPointers ? maxPointers
                : event.getPointerCount()); i++) {
            if (item.rect
                    .contains((int) event.getX(i), (int) event.getY(i)))
                pressed = true;
        }
        if (!pressed) {
            if (item.key != null && item.key.eventListener != null)
                item.key.eventListener.onReleased(item.key);
            pressedRects.remove(item);
        }
    }
    for (int i = 0; i < (event.getPointerCount() > maxPointers ? maxPointers
            : event.getPointerCount()); i++) {
        down((int) event.getX(i), (int) event.getY(i));
    }
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:21,代码来源:MutitouchKeysContainer.java

示例2: onTouchEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
	if (event.getPointerCount() > 1) {
		// Multi touch - resize the prism

		event.getPointerCoords(0, p1);
		event.getPointerCoords(1, p2);

		int a = (int) Math.abs(p1.x - p2.x);
		physics.rF = a;
		physics.rC = 2 * a;

	} else {
		// Single touch
		mouse.x = (int) event.getX();
		mouse.y = (int) event.getY();
	}
	invalidate();
	return true;
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:21,代码来源:Microscope.java

示例3: createFireEventParam

import android.view.MotionEvent; //导入方法依赖的package包/类
/**
 * Create a map represented touch event at a certain moment.
 * @param motionEvent motionEvent, which contains all pointers event in a period of time
 * @param pos index used to retrieve a certain moment in a period of time.
 * @return touchEvent
 * @see <a href="https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent">touchEvent</a>
 */
private Map<String, Object> createFireEventParam(MotionEvent motionEvent, int pos, String state) {
  JSONArray jsonArray = new JSONArray(motionEvent.getPointerCount());
  if (motionEvent.getActionMasked() == MotionEvent.ACTION_MOVE) {
    for (int i = 0; i < motionEvent.getPointerCount(); i++) {
      jsonArray.add(createJSONObject(motionEvent, pos, i));
    }
  } else if (isPointerNumChanged(motionEvent)) {
    int pointerIndex = motionEvent.getActionIndex();
    jsonArray.add(createJSONObject(motionEvent, CUR_EVENT, pointerIndex));
  }
  Map<String, Object> map = new HashMap<>();
  map.put(GestureInfo.HISTORICAL_XY, jsonArray);
  if (state != null) {
    map.put(GestureInfo.STATE, state);
  }
  return map;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:25,代码来源:WXGesture.java

示例4: dumpMotionEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
/**
 * Show an event in the LogCat view, for debugging
 */
public static void dumpMotionEvent(MotionEvent event) {
    String names[] = {"DOWN", "UP", "MOVE", "CANCEL", "OUTSIDE", "POINTER_DOWN", "POINTER_UP", "7?", "8?", "9?"};
    StringBuilder sb = new StringBuilder();
    int action = event.getAction();
    int actionCode = action & MotionEvent.ACTION_MASK;
    sb.append("event ACTION_").append(names[actionCode]);
    if (actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP) {
        sb.append("(pid ").append(action >> MotionEvent.ACTION_POINTER_INDEX_SHIFT);
        sb.append(")");
    }
    sb.append("[");
    for (int i = 0; i < event.getPointerCount(); i++) {
        sb.append("#").append(i);
        sb.append("(pid ").append(event.getPointerId(i));
        sb.append(")=").append((int) event.getX(i));
        sb.append(",").append((int) event.getY(i));
        if (i + 1 < event.getPointerCount()) {
            sb.append(";");
        }
    }
    sb.append("]");
    MLog.d(TAG, sb.toString());
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:27,代码来源:AndroidUtils.java

示例5: updateStateByEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
protected void updateStateByEvent(MotionEvent curr) {
    super.updateStateByEvent(curr);

    final MotionEvent prev = mPrevEvent;

    // Focus intenal
    mCurrFocusInternal = determineFocalPoint(curr);
    mPrevFocusInternal = determineFocalPoint(prev);

    // Focus external
    // - Prevent skipping of focus delta when a finger is added or removed
    boolean mSkipNextMoveEvent = prev.getPointerCount() != curr.getPointerCount();
    mFocusDeltaExternal = mSkipNextMoveEvent ? FOCUS_DELTA_ZERO : new PointF(mCurrFocusInternal.x - mPrevFocusInternal.x, mCurrFocusInternal.y - mPrevFocusInternal.y);

    // - Don't directly use mFocusInternal (or skipping will occur). Add
    // 	 unskipped delta values to mFocusExternal instead.
    mFocusExternal.x += mFocusDeltaExternal.x;
    mFocusExternal.y += mFocusDeltaExternal.y;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:20,代码来源:MoveGestureDetector.java

示例6: findNewActiveIndex

import android.view.MotionEvent; //导入方法依赖的package包/类
private int findNewActiveIndex(MotionEvent ev, int otherActiveId, int removedPointerIndex) {
    final int pointerCount = ev.getPointerCount();

    // It's ok if this isn't found and returns -1, it simply won't match.
    final int otherActiveIndex = ev.findPointerIndex(otherActiveId);

    // Pick a new id and update tracking state.
    for (int i = 0; i < pointerCount; i++) {
        if (i != removedPointerIndex && i != otherActiveIndex) {
            return i;
        }
    }
    return -1;
}
 
开发者ID:eventtus,项目名称:photo-editor-android,代码行数:15,代码来源:ScaleGestureDetector.java

示例7: handleScroll

import android.view.MotionEvent; //导入方法依赖的package包/类
/**
 * Handles the scroll event, determining the gesture orientation and event target,
 * when appropriate.
 * @param e1 The first down {@link MotionEvent} that started the scrolling.
 * @param e2 The move {@link MotionEvent} that triggered the current scroll.
 * @param distanceY The distance along the Y axis that has been scrolled since the last call
 *                  to handleScroll.
 * @return Whether the event has been consumed.
 */
protected boolean handleScroll(MotionEvent e1, MotionEvent e2, float distanceY) {
    // TODO(mdjones): It seems impossible that either of the two MotionEvents passed into this
    // function would be null provided the InternalGestureDetector checks them. However, it
    // still seems to be possible...
    if (e1 == null || e2 == null) return false;

    // If the panel is peeking then the swipe recognizer will handle the scroll event.
    if (mPanel.getPanelState() == PanelState.PEEKED) return false;

    // Only determines the gesture orientation if it hasn't been determined yet,
    // affectively "locking" the orientation once the gesture has started.
    if (!mHasDeterminedGestureOrientation && isDistanceGreaterThanTouchSlop(e1, e2)) {
        determineGestureOrientation(e1, e2);
    }

    // Only determines the event target after determining the gesture orientation and
    // if it hasn't been determined yet or if changing the event target during the
    // middle of the gesture is supported. This will allow a smooth transition from
    // swiping the Panel and scrolling the Content View.
    final boolean mayChangeEventTarget = mMayChangeEventTarget && e2.getPointerCount() == 1;
    if (mHasDeterminedGestureOrientation
            && (!mHasDeterminedEventTarget || mayChangeEventTarget)) {
        determineEventTarget(distanceY);
    }

    return false;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:37,代码来源:OverlayPanelEventFilter.java

示例8: getPressedPointerIndex

import android.view.MotionEvent; //导入方法依赖的package包/类
/**
 * Gets the index of the i-th pressed pointer.
 * Normally, the index will be equal to i, except in the case when the pointer is released.
 * @return index of the specified pointer or -1 if not found (i.e. not enough pointers are down)
 */
private int getPressedPointerIndex(MotionEvent event, int i) {
  final int count = event.getPointerCount();
  final int action = event.getActionMasked();
  final int index = event.getActionIndex();
  if (action == MotionEvent.ACTION_UP ||
      action == MotionEvent.ACTION_POINTER_UP) {
    if (i >= index) {
      i++;
    }
  }
  return (i < count) ? i : -1;
}
 
开发者ID:mingdroid,项目名称:tumbviewer,代码行数:18,代码来源:MultiPointerGestureDetector.java

示例9: printSamples

import android.view.MotionEvent; //导入方法依赖的package包/类
void printSamples(MotionEvent ev) {
    final int historySize = ev.getHistorySize();
    final int pointerCount = ev.getPointerCount();
    for (int h = 0; h < historySize; h++) {
        System.out.printf("At time %d:", ev.getHistoricalEventTime(h));
        for (int p = 0; p < pointerCount; p++) {
            System.out.printf("  pointer %d: (%f,%f)", ev.getPointerId(p), ev.getHistoricalX(p, h),
                    ev.getHistoricalY(p, h));
        }
    }
    System.out.printf("At time %d:", ev.getEventTime());
    for (int p = 0; p < pointerCount; p++) {
        System.out.printf("  pointer %d: (%f,%f)", ev.getPointerId(p), ev.getX(p), ev.getY(p));
    }
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:16,代码来源:PTouchPad_.java

示例10: getPressedPointerCount

import android.view.MotionEvent; //导入方法依赖的package包/类
/**
 * Gets the number of pressed pointers (fingers down).
 */
private static int getPressedPointerCount(MotionEvent event) {
    int count = event.getPointerCount();
    int action = event.getActionMasked();
    if (action == MotionEvent.ACTION_UP ||
            action == MotionEvent.ACTION_POINTER_UP) {
        count--;
    }
    return count;
}
 
开发者ID:ibosong,项目名称:CommentGallery,代码行数:13,代码来源:MultiPointerGestureDetector.java

示例11: onTouchEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            mLastX = (int) event.getRawX();
            mLastY = (int) event.getRawY();
            mFirstX = mLastX;
            mFirstY = mLastY;
            break;
        case MotionEvent.ACTION_MOVE:
            int deltaX = (int) event.getRawX() - mLastX;
            int deltaY = (int) event.getRawY() - mLastY;
            mLastX = (int) event.getRawX();
            mLastY = (int) event.getRawY();
            int totalDeltaX = mLastX - mFirstX;
            int totalDeltaY = mLastY - mFirstY;

            if (mIsMoving
                    || Math.abs(totalDeltaX) >= MOVE_THRESHOLD
                    || Math.abs(totalDeltaY) >= MOVE_THRESHOLD) {
                mIsMoving = true;
                WindowManager windowMgr = mWeakRef.get().mWindowManager;
                WindowManager.LayoutParams parm = mWeakRef.get().mWindowParam;
                if (event.getPointerCount() == 1 && windowMgr != null) {
                    parm.x -= deltaX;
                    parm.y -= deltaY;
                    windowMgr.updateViewLayout(this, parm);
                }
            }
            break;

        case MotionEvent.ACTION_UP:
            mIsMoving = false;
            break;
    }
    return true;
}
 
开发者ID:gicheonkang,项目名称:fast_face_android,代码行数:38,代码来源:FloatingCameraWindow.java

示例12: onTouchEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
    isTouch = true;
    if (event.getPointerCount() >= 2) return false;
    if (mAdapter == null) return super.onTouchEvent(event);
    int count = mAdapter.getCount();
    if (count <= 1) return super.onTouchEvent(event);
    float x = event.getRawX();
    mVelocityTracker.addMovement(event);
    int action = event.getAction();
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            if (!mScroller.isFinished()) { // 如果上次的调用没有执行完就取消。
                return false;
            }
            mLastX = x;
            return true;
        case MotionEvent.ACTION_MOVE:
            requestDisallowInterceptTouchEvent(true);
            int dxMove = (int) (mLastX - x);
            mTotalDx += dxMove;
            onScrollBy(dxMove);
            mLastX = x;
            return true;
        case MotionEvent.ACTION_UP:
            isTouch = false;
            if (Math.abs(mTotalDx) <= 10)
                performClick();
        case MotionEvent.ACTION_CANCEL: {
            final VelocityTracker velocityTracker = mVelocityTracker;
            velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
            mXVelocity = velocityTracker.getXVelocity();
            isTouch = false;
            scrollToItem();
            scrollFinish(count);
            break;
        }
    }
    return super.onTouchEvent(event);
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:41,代码来源:BannerView.java

示例13: onInterceptTouchEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    pointerCount = ev.getPointerCount();
    requestDisallowInterceptTouchEvent(pointerCount > 1);
    return super.onInterceptTouchEvent(ev);
}
 
开发者ID:martinwithaar,项目名称:PinchToZoom,代码行数:7,代码来源:ImageViewPager.java

示例14: onScroll

import android.view.MotionEvent; //导入方法依赖的package包/类
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
    if (!this.mIsPanorama && (this.mModel == null || this.mModel.isFullScreen())) {
        int s = e2.getPointerCount();
        if (s == 2) {
            this.offsetY += distanceY;
            if (this.offsetY > 0.0f) {
                if (this.offsetY > this.doubleFingersUpCuttingValue * ((float) getHeight())) {
                    this.event = 17;
                } else {
                    this.event = 0;
                }
            } else if (this.offsetY < (-this.doubleFingersDownCuttingValue) * ((float) getHeight())) {
                this.event = 16;
            } else {
                this.event = 0;
            }
        } else if (s == 1) {
            if (Math.abs(distanceY) > this.portraitLimitSlope * Math.abs(distanceX) && this.directionalLock != 2) {
                this.directionalLock = 1;
                if (e2.getX() > (1.0f - this.bothSidesCuttingValue) * ((float) getWidth())) {
                    this.rightProgerss += distanceY / ((float) getHeight());
                    setVolume(this.rightProgerss);
                    if (this.mCallbacks != null) {
                        this.mCallbacks.onRightScroll(this.rightProgerss);
                    }
                } else if (e2.getX() < this.bothSidesCuttingValue * ((float) getWidth())) {
                    this.leftProgress += distanceY / ((float) getHeight());
                    setBrightness(this.leftProgress);
                    if (this.mCallbacks != null) {
                        this.mCallbacks.onLeftScroll(this.leftProgress);
                    }
                } else if (e1.getX() > (this.middleCuttingValue - this.bothSidesCuttingValue) * ((float) getWidth()) && e1.getX() < (this.middleCuttingValue + this.bothSidesCuttingValue) * ((float) getWidth())) {
                    this.offsetY += distanceY;
                    if (!(this.mCallbacks == null && this.mModel == null)) {
                        if (this.offsetY > this.bothSidesCuttingValue * ((float) getHeight())) {
                            this.event = 20;
                        } else if (this.offsetY < (-this.bothSidesCuttingValue) * ((float) getHeight())) {
                            this.event = 19;
                        }
                    }
                }
            } else if (Math.abs(distanceY) < this.landscapeLimitSlope * Math.abs(distanceX) && this.directionalLock != 1) {
                this.directionalLock = 2;
                this.offsetX -= distanceX;
                this.landscapeProgress = this.offsetX / ((float) getWidth());
                if (!(this.mCallbacks == null || isInterceptByNavigationBar(e1))) {
                    this.mCallbacks.onLandscapeScroll(this.landscapeProgress);
                }
                this.event = 18;
            }
        }
    }
    return false;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:55,代码来源:LetvPlayGestureLayout.java

示例15: onInterceptTouchEvent

import android.view.MotionEvent; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    return ev.getPointerCount() == 2 && delegate.shouldReceiveTouches();
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:5,代码来源:EntitiesContainerView.java


注:本文中的android.view.MotionEvent.getPointerCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。