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


C# android.getPointerCount方法代码示例

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


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

示例1: ensurePointerCountIsOneForThisAction

		private void ensurePointerCountIsOneForThisAction(android.view.MotionEvent @event
			)
		{
			int pointerCount = @event.getPointerCount();
			if (pointerCount != 1)
			{
				problem("Pointer count is " + pointerCount + " but it should always be 1 for " + 
					android.view.MotionEvent.actionToString(@event.getAction()));
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:10,代码来源:InputEventConsistencyVerifier.cs

示例2: onTouch

		public virtual bool onTouch(android.view.View v, android.view.MotionEvent @event)
		{
			int action = @event.getAction();
			if (@event.getPointerCount() > 1)
			{
				// ZoomButtonsController doesn't handle mutitouch. Give up control.
				return false;
			}
			if (mReleaseTouchListenerOnUp)
			{
				// The controls were dismissed but we need to throw away all events until the up
				if (action == android.view.MotionEvent.ACTION_UP || action == android.view.MotionEvent
					.ACTION_CANCEL)
				{
					mOwnerView.setOnTouchListener(null);
					setTouchTargetView(null);
					mReleaseTouchListenerOnUp = false;
				}
				// Eat this event
				return true;
			}
			dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT);
			android.view.View targetView = mTouchTargetView;
			switch (action)
			{
				case android.view.MotionEvent.ACTION_DOWN:
				{
					targetView = findViewForTouch((int)@event.getRawX(), (int)@event.getRawY());
					setTouchTargetView(targetView);
					break;
				}

				case android.view.MotionEvent.ACTION_UP:
				case android.view.MotionEvent.ACTION_CANCEL:
				{
					setTouchTargetView(null);
					break;
				}
			}
			if (targetView != null)
			{
				// The upperleft corner of the target view in raw coordinates
				int targetViewRawX = mContainerRawLocation[0] + mTouchTargetWindowLocation[0];
				int targetViewRawY = mContainerRawLocation[1] + mTouchTargetWindowLocation[1];
				android.view.MotionEvent containerEvent = android.view.MotionEvent.obtain(@event);
				// Convert the motion event into the target view's coordinates (from
				// owner view's coordinates)
				containerEvent.offsetLocation(mOwnerViewRawLocation[0] - targetViewRawX, mOwnerViewRawLocation
					[1] - targetViewRawY);
				// These are floats because we need to potentially offset away this exact amount
				float containerX = containerEvent.getX();
				float containerY = containerEvent.getY();
				if (containerX < 0 && containerX > -ZOOM_CONTROLS_TOUCH_PADDING)
				{
					containerEvent.offsetLocation(-containerX, 0);
				}
				if (containerY < 0 && containerY > -ZOOM_CONTROLS_TOUCH_PADDING)
				{
					containerEvent.offsetLocation(0, -containerY);
				}
				bool retValue = targetView.dispatchTouchEvent(containerEvent);
				containerEvent.recycle();
				return retValue;
			}
			else
			{
				return false;
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:69,代码来源:ZoomButtonsController.cs

示例3: onTouchEvent

		/// <summary>Checks a touch event.</summary>
		/// <remarks>Checks a touch event.</remarks>
		/// <param name="event">The event.</param>
		/// <param name="nestingLevel">
		/// The nesting level: 0 if called from the base class,
		/// or 1 from a subclass.  If the event was already checked by this consistency verifier
		/// at a higher nesting level, it will not be checked again.  Used to handle the situation
		/// where a subclass dispatching method delegates to its superclass's dispatching method
		/// and both dispatching methods call into the consistency verifier.
		/// </param>
		public void onTouchEvent(android.view.MotionEvent @event, int nestingLevel)
		{
			if (!startEvent(@event, nestingLevel, EVENT_TYPE_TOUCH))
			{
				return;
			}
			int action = @event.getAction();
			bool newStream = action == android.view.MotionEvent.ACTION_DOWN || action == android.view.MotionEvent
				.ACTION_CANCEL;
			if (newStream && (mTouchEventStreamIsTainted || mTouchEventStreamUnhandled))
			{
				mTouchEventStreamIsTainted = false;
				mTouchEventStreamUnhandled = false;
				mTouchEventStreamPointers = 0;
			}
			if (mTouchEventStreamIsTainted)
			{
				@event.setTainted(true);
			}
			try
			{
				ensureMetaStateIsNormalized(@event.getMetaState());
				int deviceId = @event.getDeviceId();
				int source = @event.getSource();
				if (!newStream && mTouchEventStreamDeviceId != -1 && (mTouchEventStreamDeviceId !=
					 deviceId || mTouchEventStreamSource != source))
				{
					problem("Touch event stream contains events from multiple sources: " + "previous device id "
						 + mTouchEventStreamDeviceId + ", previous source " + Sharpen.Util.IntToHexString
						(mTouchEventStreamSource) + ", new device id " + deviceId + ", new source " + Sharpen.Util.IntToHexString
						(source));
				}
				mTouchEventStreamDeviceId = deviceId;
				mTouchEventStreamSource = source;
				int pointerCount = @event.getPointerCount();
				if ((source & android.view.InputDevice.SOURCE_CLASS_POINTER) != 0)
				{
					switch (action)
					{
						case android.view.MotionEvent.ACTION_DOWN:
						{
							if (mTouchEventStreamPointers != 0)
							{
								problem("ACTION_DOWN but pointers are already down.  " + "Probably missing ACTION_UP from previous gesture."
									);
							}
							ensureHistorySizeIsZeroForThisAction(@event);
							ensurePointerCountIsOneForThisAction(@event);
							mTouchEventStreamPointers = 1 << @event.getPointerId(0);
							break;
						}

						case android.view.MotionEvent.ACTION_UP:
						{
							ensureHistorySizeIsZeroForThisAction(@event);
							ensurePointerCountIsOneForThisAction(@event);
							mTouchEventStreamPointers = 0;
							mTouchEventStreamIsTainted = false;
							break;
						}

						case android.view.MotionEvent.ACTION_MOVE:
						{
							int expectedPointerCount = Sharpen.Util.IntGetBitCount(mTouchEventStreamPointers);
							if (pointerCount != expectedPointerCount)
							{
								problem("ACTION_MOVE contained " + pointerCount + " pointers but there are currently "
									 + expectedPointerCount + " pointers down.");
								mTouchEventStreamIsTainted = true;
							}
							break;
						}

						case android.view.MotionEvent.ACTION_CANCEL:
						{
							mTouchEventStreamPointers = 0;
							mTouchEventStreamIsTainted = false;
							break;
						}

						case android.view.MotionEvent.ACTION_OUTSIDE:
						{
							if (mTouchEventStreamPointers != 0)
							{
								problem("ACTION_OUTSIDE but pointers are still down.");
							}
							ensureHistorySizeIsZeroForThisAction(@event);
							ensurePointerCountIsOneForThisAction(@event);
							mTouchEventStreamIsTainted = false;
							break;
//.........这里部分代码省略.........
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:101,代码来源:InputEventConsistencyVerifier.cs

示例4: findNewActiveIndex

		private int findNewActiveIndex(android.view.MotionEvent ev, int otherActiveId, int
			 oldIndex)
		{
			int pointerCount = ev.getPointerCount();
			// It's ok if this isn't found and returns -1, it simply won't match.
			int otherActiveIndex = ev.findPointerIndex(otherActiveId);
			int newActiveIndex = -1;
			{
				// Pick a new id and update tracking state. Only pick pointers not on the slop edges.
				for (int i = 0; i < pointerCount; i++)
				{
					if (i != oldIndex && i != otherActiveIndex)
					{
						float edgeSlop = mEdgeSlop;
						float rightSlop = mRightSlopEdge;
						float bottomSlop = mBottomSlopEdge;
						float x = getRawX(ev, i);
						float y = getRawY(ev, i);
						if (x >= edgeSlop && y >= edgeSlop && x <= rightSlop && y <= bottomSlop)
						{
							newActiveIndex = i;
							break;
						}
					}
				}
			}
			return newActiveIndex;
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:28,代码来源:ScaleGestureDetector.cs

示例5: onTouchEvent


//.........这里部分代码省略.........
								{
									mFocusX = -1;
									mFocusY = -1;
								}
								else
								{
									if (p0sloppy)
									{
										mFocusX = @event.getX(index1);
										mFocusY = @event.getY(index1);
									}
									else
									{
										if (p1sloppy)
										{
											mFocusX = @event.getX(index0);
											mFocusY = @event.getY(index0);
										}
										else
										{
											mSloppyGesture = false;
											mGestureInProgress = mListener.onScaleBegin(this);
										}
									}
								}
							}
							break;
						}

						case android.view.MotionEvent.ACTION_POINTER_UP:
						{
							if (mSloppyGesture)
							{
								int pointerCount = @event.getPointerCount();
								int actionIndex = @event.getActionIndex();
								int actionId = @event.getPointerId(actionIndex);
								if (pointerCount > 2)
								{
									if (actionId == mActiveId0)
									{
										int newIndex = findNewActiveIndex(@event, mActiveId1, actionIndex);
										if (newIndex >= 0)
										{
											mActiveId0 = @event.getPointerId(newIndex);
										}
									}
									else
									{
										if (actionId == mActiveId1)
										{
											int newIndex = findNewActiveIndex(@event, mActiveId0, actionIndex);
											if (newIndex >= 0)
											{
												mActiveId1 = @event.getPointerId(newIndex);
											}
										}
									}
								}
								else
								{
									// Set focus point to the remaining finger
									int index = @event.findPointerIndex(actionId == mActiveId0 ? mActiveId1 : mActiveId0
										);
									if (index < 0)
									{
										mInvalidGesture = true;
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:67,代码来源:ScaleGestureDetector.cs

示例6: onSecondaryPointerUp

		private void onSecondaryPointerUp(android.view.MotionEvent ev)
		{
			int activePointerIndex = ev.getActionIndex();
			int pointerId = ev.getPointerId(activePointerIndex);
			if (pointerId == mActivePointerId)
			{
				int activeViewIndex = (mSwipeGestureType == GESTURE_SLIDE_DOWN) ? 0 : 1;
				android.view.View v = getViewAtRelativeIndex(activeViewIndex);
				if (v == null)
				{
					return;
				}
				{
					// Our primary pointer has gone up -- let's see if we can find
					// another pointer on the view. If so, then we should replace
					// our primary pointer with this new pointer and adjust things
					// so that the view doesn't jump
					for (int index = 0; index < ev.getPointerCount(); index++)
					{
						if (index != activePointerIndex)
						{
							float x = ev.getX(index);
							float y = ev.getY(index);
							mTouchRect.set(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
							if (mTouchRect.contains(Sharpen.Util.Round(x), Sharpen.Util.Round(y)))
							{
								float oldX = ev.getX(activePointerIndex);
								float oldY = ev.getY(activePointerIndex);
								// adjust our frame of reference to avoid a jump
								mInitialY += (y - oldY);
								mInitialX += (x - oldX);
								mActivePointerId = ev.getPointerId(index);
								if (mVelocityTracker != null)
								{
									mVelocityTracker.clear();
								}
								// ok, we're good, we found a new pointer which is touching the active view
								return;
							}
						}
					}
				}
				// if we made it this far, it means we didn't find a satisfactory new pointer :(,
				// so end the gesture
				handlePointerUp(ev);
			}
		}
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:47,代码来源:StackView.cs

示例7: onTouchEvent

		/// <summary>
		/// Analyzes the given motion event and if applicable triggers the
		/// appropriate callbacks on the
		/// <see cref="OnGestureListener">OnGestureListener</see>
		/// supplied.
		/// </summary>
		/// <param name="ev">The current motion event.</param>
		/// <returns>
		/// true if the
		/// <see cref="OnGestureListener">OnGestureListener</see>
		/// consumed the event,
		/// else false.
		/// </returns>
		public virtual bool onTouchEvent(android.view.MotionEvent ev)
		{
			if (mInputEventConsistencyVerifier != null)
			{
				mInputEventConsistencyVerifier.onTouchEvent(ev, 0);
			}
			int action = ev.getAction();
			float y = ev.getY();
			float x = ev.getX();
			if (mVelocityTracker == null)
			{
				mVelocityTracker = android.view.VelocityTracker.obtain();
			}
			mVelocityTracker.addMovement(ev);
			bool handled = false;
			switch (action & android.view.MotionEvent.ACTION_MASK)
			{
				case android.view.MotionEvent.ACTION_POINTER_DOWN:
				{
					if (mIgnoreMultitouch)
					{
						// Multitouch event - abort.
						cancel();
					}
					break;
				}

				case android.view.MotionEvent.ACTION_POINTER_UP:
				{
					// Ending a multitouch gesture and going back to 1 finger
					if (mIgnoreMultitouch && ev.getPointerCount() == 2)
					{
						int index = (((action & android.view.MotionEvent.ACTION_POINTER_INDEX_MASK) >> android.view.MotionEvent
							.ACTION_POINTER_INDEX_SHIFT) == 0) ? 1 : 0;
						mLastMotionX = ev.getX(index);
						mLastMotionY = ev.getY(index);
						mVelocityTracker.recycle();
						mVelocityTracker = android.view.VelocityTracker.obtain();
					}
					break;
				}

				case android.view.MotionEvent.ACTION_DOWN:
				{
					if (mDoubleTapListener != null)
					{
						bool hadTapMessage = mHandler.hasMessages(TAP);
						if (hadTapMessage)
						{
							mHandler.removeMessages(TAP);
						}
						if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null) && hadTapMessage &&
							 isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev))
						{
							// This is a second tap
							mIsDoubleTapping = true;
							// Give a callback with the first tap of the double-tap
							handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent);
							// Give a callback with down event of the double-tap
							handled |= mDoubleTapListener.onDoubleTapEvent(ev);
						}
						else
						{
							// This is a first tap
							mHandler.sendEmptyMessageDelayed(TAP, DOUBLE_TAP_TIMEOUT);
						}
					}
					mLastMotionX = x;
					mLastMotionY = y;
					if (mCurrentDownEvent != null)
					{
						mCurrentDownEvent.recycle();
					}
					mCurrentDownEvent = android.view.MotionEvent.obtain(ev);
					mAlwaysInTapRegion = true;
					mAlwaysInBiggerTapRegion = true;
					mStillDown = true;
					mInLongPress = false;
					if (mIsLongpressEnabled)
					{
						mHandler.removeMessages(LONG_PRESS);
						mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime() + TAP_TIMEOUT
							 + LONGPRESS_TIMEOUT);
					}
					mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + TAP_TIMEOUT
						);
					handled |= mListener.onDown(ev);
//.........这里部分代码省略.........
开发者ID:hakeemsm,项目名称:XobotOS,代码行数:101,代码来源:GestureDetector.cs


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