本文整理了Java中android.view.MotionEvent.getDownTime()
方法的一些代码示例,展示了MotionEvent.getDownTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.getDownTime()
方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:getDownTime
暂无
代码示例来源:origin: termux/termux-app
/** Send a single mouse event code to the terminal. */
void sendMouseEventCode(MotionEvent e, int button, boolean pressed) {
int x = (int) (e.getX() / mRenderer.mFontWidth) + 1;
int y = (int) ((e.getY() - mRenderer.mFontLineSpacingAndAscent) / mRenderer.mFontLineSpacing) + 1;
if (pressed && (button == TerminalEmulator.MOUSE_WHEELDOWN_BUTTON || button == TerminalEmulator.MOUSE_WHEELUP_BUTTON)) {
if (mMouseStartDownTime == e.getDownTime()) {
x = mMouseScrollStartX;
y = mMouseScrollStartY;
} else {
mMouseStartDownTime = e.getDownTime();
mMouseScrollStartX = x;
mMouseScrollStartY = y;
}
}
mEmulator.sendMouseEvent(button, x, y, pressed);
}
代码示例来源:origin: alexvasilkov/GestureViews
private static MotionEvent obtainOnePointerEvent(@NonNull MotionEvent event) {
return MotionEvent.obtain(event.getDownTime(), event.getEventTime(), event.getAction(),
event.getX(), event.getY(), event.getMetaState());
}
代码示例来源:origin: h6ah4i/android-advancedrecyclerview
public void startLongPressDetection(MotionEvent e, int timeout) {
cancelLongPressDetection();
mDownMotionEvent = MotionEvent.obtain(e);
sendEmptyMessageAtTime(MSG_LONGPRESS, e.getDownTime() + timeout);
}
代码示例来源:origin: h6ah4i/android-advancedrecyclerview
public void startLongPressDetection(MotionEvent e, int timeout) {
cancelLongPressDetection();
mDownMotionEvent = MotionEvent.obtain(e);
sendEmptyMessageAtTime(MSG_LONGPRESS, e.getDownTime() + timeout);
}
代码示例来源:origin: ankidroid/Anki-Android
/** Tap onto the currently shown flashcard at position x and y
*
* @param x horizontal position of the event
* @param y vertical position of the event
*/
public void tapOnCurrentCard(int x, int y) {
// assemble suitable ACTION_DOWN and ACTION_UP events and forward them to the card's handler
MotionEvent eDown = MotionEvent.obtain(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, x, y,
1, 1, 0, 1, 1, 0, 0);
mCard.dispatchTouchEvent(eDown);
MotionEvent eUp = MotionEvent.obtain(eDown.getDownTime(),
SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y,
1, 1, 0, 1, 1, 0, 0);
mCard.dispatchTouchEvent(eUp);
}
代码示例来源:origin: tumblr/Backboard
if (event.getEventTime() - event.getDownTime()
> ViewConfiguration.getLongPressTimeout()) {
v.setPressed(false);
代码示例来源:origin: TonicArtos/StickyGridHeaders
private MotionEvent transformEvent(MotionEvent e, int headerPosition) {
if (headerPosition == MATCHED_STICKIED_HEADER) {
return e;
}
long downTime = e.getDownTime();
long eventTime = e.getEventTime();
int action = e.getAction();
int pointerCount = e.getPointerCount();
int[] pointerIds = getPointerIds(e);
MotionEvent.PointerCoords[] pointerCoords = getPointerCoords(e);
int metaState = e.getMetaState();
float xPrecision = e.getXPrecision();
float yPrecision = e.getYPrecision();
int deviceId = e.getDeviceId();
int edgeFlags = e.getEdgeFlags();
int source = e.getSource();
int flags = e.getFlags();
View headerHolder = getChildAt(headerPosition);
for (int i = 0; i < pointerCount;i++) {
pointerCoords[i].y -= headerHolder.getTop();
}
MotionEvent n = MotionEvent.obtain(downTime, eventTime, action,
pointerCount, pointerIds, pointerCoords, metaState, xPrecision,
yPrecision, deviceId, edgeFlags, source, flags);
return n;
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testWriteToParcel() {
Parcel parcel = Parcel.obtain();
motionEvent2.writeToParcel(parcel, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
parcel.setDataPosition(0);
MotionEvent motionEvent = MotionEvent.CREATOR.createFromParcel(parcel);
assertThat(motionEvent).rawY().isWithin(TOLERANCE).of(motionEvent2.getRawY());
assertThat(motionEvent).rawX().isWithin(TOLERANCE).of(motionEvent2.getRawX());
assertThat(motionEvent).y().isWithin(TOLERANCE).of(motionEvent2.getY());
assertThat(motionEvent).x().isWithin(TOLERANCE).of(motionEvent2.getX());
assertThat(motionEvent).hasAction(motionEvent2.getAction());
assertThat(motionEvent).hasDownTime(motionEvent2.getDownTime());
assertThat(motionEvent).hasEventTime(motionEvent2.getEventTime());
assertThat(motionEvent).hasEdgeFlags(motionEvent2.getEdgeFlags());
assertThat(motionEvent).hasDeviceId(motionEvent2.getDeviceId());
}
代码示例来源:origin: w1123440793/VideoListDemo
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.e("custommedia", "event");
Rect seekRect = new Rect();
seekBar.getHitRect(seekRect);
if ((event.getY() >= (seekRect.top - 50)) && (event.getY() <= (seekRect.bottom + 50))) {
float y = seekRect.top + seekRect.height() / 2;
//seekBar only accept relative x
float x = event.getX() - seekRect.left;
if (x < 0) {
x = 0;
} else if (x > seekRect.width()) {
x = seekRect.width();
}
MotionEvent me = MotionEvent.obtain(event.getDownTime(), event.getEventTime(),
event.getAction(), x, y, event.getMetaState());
return seekBar.onTouchEvent(me);
}
return false;
}
});
代码示例来源:origin: huxq17/XRefreshView
private void sendDownEvent() {
if (!mHasSendDownEvent) {
LogUtils.d("sendDownEvent");
mHasSendCancelEvent = false;
mHasSendDownEvent = true;
isIntercepted = false;
final MotionEvent last = mLastMoveEvent;
if (last == null)
return;
MotionEvent e = MotionEvent.obtain(last.getDownTime(),
last.getEventTime(), MotionEvent.ACTION_DOWN, last.getX(),
last.getY(), last.getMetaState());
dispatchTouchEventSupper(e);
}
}
代码示例来源:origin: robinhood/spark
case MotionEvent.ACTION_MOVE:
float timeDelta = event.getEventTime() - event.getDownTime();
代码示例来源:origin: robinhood/spark
private MotionEvent getMotionEvent(int action, float x, float y, long eventTime, long downTime) {
MotionEvent motionEvent = Mockito.mock(MotionEvent.class);
when(motionEvent.getX()).thenReturn(x);
when(motionEvent.getY()).thenReturn(y);
when(motionEvent.getEventTime()).thenReturn(eventTime);
when(motionEvent.getDownTime()).thenReturn(downTime);
when(motionEvent.getActionMasked()).thenReturn(action);
return motionEvent;
}
}
代码示例来源:origin: blipinsk/RecyclerViewHeader
@Override
@CallSuper
public boolean onTouchEvent(@NonNull MotionEvent event) {
if (recyclerWantsTouch) { // this cannot be true if recycler is not attached
int scrollDiff = downTranslation - calculateTranslation();
int verticalDiff = isVertical ? scrollDiff : 0;
int horizontalDiff = isVertical ? 0 : scrollDiff;
MotionEvent recyclerEvent =
MotionEvent.obtain(event.getDownTime(),
event.getEventTime(),
event.getAction(),
event.getX() - horizontalDiff,
event.getY() - verticalDiff,
event.getMetaState());
recyclerView.onTouchEvent(recyclerEvent);
return false;
}
return super.onTouchEvent(event);
}
代码示例来源:origin: huxq17/XRefreshView
private void sendCancelEvent() {
if (!mHasSendCancelEvent) {
LogUtils.d("sendCancelEvent");
setRefreshTime();
mHasSendCancelEvent = true;
mHasSendDownEvent = false;
MotionEvent last = mLastMoveEvent;
MotionEvent e = MotionEvent.obtain(
last.getDownTime(),
last.getEventTime()
+ ViewConfiguration.getLongPressTimeout(),
MotionEvent.ACTION_CANCEL, last.getX(), last.getY(),
last.getMetaState());
dispatchTouchEventSupper(e);
}
}
代码示例来源:origin: stackoverflow.com
case MotionEvent.ACTION_DOWN:
if(mFirstDownTime == 0 || event.getEventTime() - mFirstDownTime > TIMEOUT)
reset(event.getDownTime());
break;
case MotionEvent.ACTION_POINTER_UP:
代码示例来源:origin: robolectric/robolectric
check("getDownTime()").that(actual().getDownTime()).isEqualTo(other.getDownTime());
check("getEventTime()").that(actual().getEventTime()).isEqualTo(other.getEventTime());
check("action()").that(actual().getAction()).isEqualTo(other.getAction());
代码示例来源:origin: recruit-lifestyle/FloatingView
mTouchDownTime = event.getDownTime();
if (mTouchDownTime != event.getDownTime()) {
return true;
mLongPressHandler.removeMessages(LongPressHandler.LONG_PRESSED);
if (mTouchDownTime != event.getDownTime()) {
return true;
代码示例来源:origin: ome450901/SimpleRatingBar
static boolean isClickEvent(float startX, float startY, MotionEvent event) {
float duration = event.getEventTime() - event.getDownTime();
if (duration > MAX_CLICK_DURATION) {
return false;
}
float differenceX = Math.abs(startX - event.getX());
float differenceY = Math.abs(startY - event.getY());
return !(differenceX > MAX_CLICK_DISTANCE || differenceY > MAX_CLICK_DISTANCE);
}
代码示例来源:origin: NEYouFan/ht-refreshrecyclerview
protected void sendDownEvent() {
final MotionEvent last = mLastMoveEvent;
MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime(), MotionEvent.ACTION_DOWN, last.getX(), last.getY(), last.getMetaState());
defaultDispatchTouchEvent(e);
}
代码示例来源:origin: techery/progresshint
@SuppressLint("ClickableViewAccessibility")
@Override public boolean onTouch(View v, MotionEvent event) {
PointF coordinates = getHintDragCoordinates(event);
MotionEvent modifiedEvent = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), event.getAction(),
coordinates.x, coordinates.y, event.getMetaState()
);
boolean dispatched = mSeekBar.dispatchTouchEvent(modifiedEvent);
modifiedEvent.recycle();
return dispatched;
}
};
内容来源于网络,如有侵权,请联系作者删除!