android.view.MotionEvent.getMetaState()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中android.view.MotionEvent.getMetaState()方法的一些代码示例,展示了MotionEvent.getMetaState()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.getMetaState()方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:getMetaState

MotionEvent.getMetaState介绍

暂无

代码示例

代码示例来源: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: 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: 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: 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: 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: Justson/AgentWebX5

private void sendDownEvent() {
  final MotionEvent last = mLastMoveEvent;
  MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime(), MotionEvent.ACTION_DOWN, last.getX(), last.getY(), last.getMetaState());
  cp.dispatchTouchEventSuper(e);
}

代码示例来源:origin: captain-miao/RecyclerViewUtils

private void sendDownEvent() {
  if (DEBUG) {
    PtrCLog.d(LOG_TAG, "send down event");
  }
  final MotionEvent last = mLastMoveEvent;
  MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime(), MotionEvent.ACTION_DOWN, last.getX(), last.getY(), last.getMetaState());
  dispatchTouchEventSupper(e);
}

代码示例来源:origin: tengyukun/pulltorefreshRecylerView

private void sendDownEvent() {
  if (DEBUG) {
    PtrCLog.d(LOG_TAG, "send down event");
  }
  final MotionEvent last = mLastMoveEvent;
  MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime(), MotionEvent.ACTION_DOWN, last.getX(), last.getY(), last.getMetaState());
  dispatchTouchEventSupper(e);
}

代码示例来源:origin: baiiu/ZhihuDaily

private void sendDownEvent() {
  if (DEBUG) {
    PtrCLog.d(LOG_TAG, "send down event");
  }
  final MotionEvent last = mLastMoveEvent;
  MotionEvent e =
      MotionEvent.obtain(last.getDownTime(), last.getEventTime(), MotionEvent.ACTION_DOWN, last.getX(),
                last.getY(), last.getMetaState());
  dispatchTouchEventSupper(e);
}

代码示例来源:origin: com.github.japgolly.android.test/robolectric

@Implementation
public static MotionEvent obtain(MotionEvent motionEvent) {
  return obtain(motionEvent.getDownTime(), motionEvent.getEventTime(), motionEvent.getAction(), motionEvent.getX(), motionEvent.getY(), motionEvent.getMetaState());
}

代码示例来源:origin: Justson/AgentWebX5

private void sendCancelEvent() {
  if (mLastMoveEvent == null) {
    return;
  }
  MotionEvent last = mLastMoveEvent;
  MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime() + ViewConfiguration.getLongPressTimeout(), MotionEvent.ACTION_CANCEL, last.getX(), last.getY(), last.getMetaState());
  cp.dispatchTouchEventSuper(e);
}

代码示例来源:origin: zzkong/BaseProject

private void sendDownEvent() {
  if (DEBUG) {
    PtrCLog.d(LOG_TAG, "send down event");
  }
  final MotionEvent last = mLastMoveEvent;
  MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime(), MotionEvent.ACTION_DOWN, last.getX(), last.getY(), last.getMetaState());
  dispatchTouchEventSupper(e);
}

代码示例来源:origin: NEYouFan/ht-refreshrecyclerview

protected void sendCancelEvent() {
  // The ScrollJob will update position and lead to send cancel event when mLastMoveEvent is null.
  if (mLastMoveEvent == null) {
    return;
  }
  MotionEvent last = mLastMoveEvent;
  MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime() + ViewConfiguration.getLongPressTimeout(), MotionEvent.ACTION_CANCEL, last.getX(), last.getY(), last.getMetaState());
  defaultDispatchTouchEvent(e);
}

代码示例来源:origin: xu649526275/MyMVPDemo

private void sendDownEvent() {
  if (DEBUG) {
    PtrCLog.d(LOG_TAG, "send down event");
  }
  final MotionEvent last = mLastMoveEvent;
  MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime(), MotionEvent.ACTION_DOWN, last.getX(), last.getY(), last.getMetaState());
  dispatchTouchEventSupper(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;
 }
};

代码示例来源:origin: xu649526275/MyMVPDemo

private void sendCancelEvent() {
  if (DEBUG) {
    PtrCLog.d(LOG_TAG, "send cancel event");
  }
  // The ScrollChecker will update position and lead to send cancel event when mLastMoveEvent is null.
  // fix #104, #80, #92
  if (mLastMoveEvent == null) {
    return;
  }
  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: tengyukun/pulltorefreshRecylerView

private void sendCancelEvent() {
  if (DEBUG) {
    PtrCLog.d(LOG_TAG, "send cancel event");
  }
  // The ScrollChecker will update position and lead to send cancel event when mLastMoveEvent is null.
  // fix #104, #80, #92
  if (mLastMoveEvent == null) {
    return;
  }
  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: tony-Shx/Swface

private void sendCancelEvent() {
  if (DEBUG) {
    PtrCLog.d(LOG_TAG, "send cancel event");
  }
  // The ScrollChecker will update position and lead to send cancel event when mLastMoveEvent is null.
  // fix #104, #80, #92
  if (mLastMoveEvent == null) {
    return;
  }
  MotionEvent last = mLastMoveEvent;
  MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime() + ViewConfiguration.getLongPressTimeout(), MotionEvent.ACTION_CANCEL, last.getX(), last.getY(), last.getMetaState());
  dispatchTouchEventSupper(e);
}

相关文章