• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java GestureInfo类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.taobao.weex.ui.view.gesture.WXGestureType.GestureInfo的典型用法代码示例。如果您正苦于以下问题:Java GestureInfo类的具体用法?Java GestureInfo怎么用?Java GestureInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

GestureInfo类属于com.taobao.weex.ui.view.gesture.WXGestureType包,在下文中一共展示了GestureInfo类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createFireEventParam

点赞 3

import com.taobao.weex.ui.view.gesture.WXGestureType.GestureInfo; //导入依赖的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

示例2: createFireEventParam

点赞 2

import com.taobao.weex.ui.view.gesture.WXGestureType.GestureInfo; //导入依赖的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) {
  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);
  return map;
}
 

开发者ID:amap-demo,
项目名称:weex-3d-map,
代码行数:22,
代码来源:WXGesture.java

示例3: createJSONObject

点赞 2

import com.taobao.weex.ui.view.gesture.WXGestureType.GestureInfo; //导入依赖的package包/类
/**
 * Create a touchObject for a pointer at a certain moment.
 * @param screenXY the point of event happened in screen coordinate
 * @param pageXY the point of event happened in page coorindate
 * @param pointerId pointerIndex pointerIndex
 * @return JSONObject represent a touch event
 * @see <a href="https://developer.mozilla.org/en-US/docs/Web/API/Touch">touch</a>
 */
@NonNull
private JSONObject createJSONObject(PointF screenXY, PointF pageXY, float pointerId) {
  JSONObject jsonObject = new JSONObject();
  jsonObject.put(GestureInfo.PAGE_X, pageXY.x);
  jsonObject.put(GestureInfo.PAGE_Y, pageXY.y);
  jsonObject.put(GestureInfo.SCREEN_X, screenXY.x);
  jsonObject.put(GestureInfo.SCREEN_Y, screenXY.y);
  jsonObject.put(GestureInfo.POINTER_ID, pointerId);
  return jsonObject;
}
 

开发者ID:amap-demo,
项目名称:weex-3d-map,
代码行数:19,
代码来源:WXGesture.java

示例4: onScroll

点赞 2

import com.taobao.weex.ui.view.gesture.WXGestureType.GestureInfo; //导入依赖的package包/类
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
  boolean result = false;
  if (containsPan() &&
      (e2.getPointerId(e1.getActionIndex()) == e1.getPointerId(e1.getActionIndex()))) {
    if (panDownTime != e1.getEventTime()) {
      panDownTime = e1.getEventTime();
      scrolling = true;
      component.getInstance().fireEvent(
                                           component.getDomObject().getRef(), HighLevelGesture.PAN_START.toString(),
                                           createFireEventParam(e1, CUR_EVENT));
    } else {
      component.getInstance().fireEvent(
                                           component.getDomObject().getRef(), HighLevelGesture.PAN_MOVE.toString(),
                                           createFireEventParam(e2, CUR_EVENT));
    }
    result = true;
  }
  if (component.containsGesture(HighLevelGesture.SWIPE)) {
    if (swipeDownTime != e1.getEventTime()) {
      swipeDownTime = e1.getEventTime();
      List<Map<String, Object>> list = createFireEventParam(e2);
      Map<String, Object> param = list.get(list.size() - 1);
      if (Math.abs(distanceX) > Math.abs(distanceY)) {
        param.put(GestureInfo.DIRECTION, distanceX > 0 ? "left" : "right");
      } else {
        param.put(GestureInfo.DIRECTION, distanceY > 0 ? "up" : "down");
      }
      component.getInstance().fireEvent( component.getDomObject().getRef(),
                                           HighLevelGesture.SWIPE.toString(), param);
      result = true;
    }
  }
  return result;
}
 

开发者ID:amap-demo,
项目名称:weex-3d-map,
代码行数:36,
代码来源:WXGesture.java

示例5: onScroll

点赞 2

import com.taobao.weex.ui.view.gesture.WXGestureType.GestureInfo; //导入依赖的package包/类
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
  boolean result = false;
  if (containsPan() &&
      (e2.getPointerId(e1.getActionIndex()) == e1.getPointerId(e1.getActionIndex()))) {
    if (panDownTime != e1.getEventTime()) {
      panDownTime = e1.getEventTime();
      scrolling = true;
      WXSDKManager.getInstance().fireEvent(component.mInstanceId,
                                           component.mDomObj.ref, HighLevelGesture.PAN_START.toString(),
                                           createFireEventParam(e1, CUR_EVENT));
    } else {
      WXSDKManager.getInstance().fireEvent(component.mInstanceId,
                                           component.mDomObj.ref, HighLevelGesture.PAN_MOVE.toString(),
                                           createFireEventParam(e2, CUR_EVENT));
    }
    result = true;
  }
  if (component.containsGesture(HighLevelGesture.SWIPE)) {
    if (swipeDownTime != e1.getEventTime()) {
      swipeDownTime = e1.getEventTime();
      List<Map<String, Object>> list = createFireEventParam(e2);
      Map<String, Object> param = list.get(list.size() - 1);
      if (Math.abs(distanceX) > Math.abs(distanceY)) {
        param.put(GestureInfo.DIRECTION, distanceX > 0 ? "left" : "right");
      } else {
        param.put(GestureInfo.DIRECTION, distanceY > 0 ? "up" : "down");
      }
      WXSDKManager.getInstance().fireEvent(component.mInstanceId, component.mDomObj.ref,
                                           HighLevelGesture.SWIPE.toString(), param);
      result = true;
    }
  }
  return result;
}
 

开发者ID:Laisly,
项目名称:weex,
代码行数:36,
代码来源:WXGesture.java

示例6: onScroll

点赞 2

import com.taobao.weex.ui.view.gesture.WXGestureType.GestureInfo; //导入依赖的package包/类
/**
 * Gesture priority:horizontalPan & verticalPan > pan > swipe
 */
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
  boolean result = false;
  if (e1 == null || e2 == null) {
    return false;
  }
  float dx = Math.abs(e2.getX() - e1.getX());
  float dy = Math.abs(e2.getY() - e1.getY());
  WXGestureType possiblePan;
  if (dx > dy) {
    possiblePan = HighLevelGesture.HORIZONTALPAN;
  } else {
    possiblePan = HighLevelGesture.VERTICALPAN;
  }
  if (mPendingPan == HighLevelGesture.HORIZONTALPAN || mPendingPan == HighLevelGesture.VERTICALPAN) {
    //already during directional-pan
    handlePanMotionEvent(e2);
    result = true;
  } else if (component.containsGesture(possiblePan)) {
    ViewParent p;
    if ((p = component.getRealView().getParent()) != null) {
      p.requestDisallowInterceptTouchEvent(true);
    }
    if (mPendingPan != null) {
      handleMotionEvent(mPendingPan, e2);//finish pan if exist
    }
    mPendingPan = possiblePan;
    component.fireEvent(possiblePan.toString(), createFireEventParam(e2, CUR_EVENT, START));

    result = true;
  } else if (containsSimplePan()) {
    if (panDownTime != e1.getEventTime()) {
      panDownTime = e1.getEventTime();
      mPendingPan = HighLevelGesture.PAN_END;
      component.fireEvent(HighLevelGesture.PAN_START.toString(),
          createFireEventParam(e1, CUR_EVENT, null));
    } else {
      component.fireEvent(HighLevelGesture.PAN_MOVE.toString(),
          createFireEventParam(e2, CUR_EVENT, null));
    }
    result = true;
  } else if (component.containsGesture(HighLevelGesture.SWIPE)) {
    if (swipeDownTime != e1.getEventTime()) {
      swipeDownTime = e1.getEventTime();
      List<Map<String, Object>> list = createMultipleFireEventParam(e2, null);
      Map<String, Object> param = list.get(list.size() - 1);
      if (Math.abs(distanceX) > Math.abs(distanceY)) {
        param.put(GestureInfo.DIRECTION, distanceX > 0 ? LEFT : RIGHT);
      } else {
        param.put(GestureInfo.DIRECTION, distanceY > 0 ? UP : DOWN);
      }
      component.getInstance().fireEvent(component.getDomObject().getRef(),
          HighLevelGesture.SWIPE.toString(), param);
      result = true;
    }
  }
  mIsTouchEventConsumed = mIsTouchEventConsumed || result;
  return result;
}
 

开发者ID:weexext,
项目名称:ucar-weex-core,
代码行数:63,
代码来源:WXGesture.java

示例7: onScroll

点赞 2

import com.taobao.weex.ui.view.gesture.WXGestureType.GestureInfo; //导入依赖的package包/类
/**
 * Gesture priority:horizontalPan & verticalPan > pan > swipe
 */
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
  boolean result = false;
  if (e1 == null || e2 == null) {
    return false;
  }
  float dx = Math.abs(e2.getX() - e1.getX());
  float dy = Math.abs(e2.getY() - e1.getY());
  WXGestureType possiblePan;
  if (dx > dy) {
    possiblePan = HighLevelGesture.HORIZONTALPAN;
  } else {
    possiblePan = HighLevelGesture.VERTICALPAN;
  }
  if (mPendingPan == HighLevelGesture.HORIZONTALPAN || mPendingPan == HighLevelGesture.VERTICALPAN) {
    //already during directional-pan
    handlePanMotionEvent(e2);
    result = true;
  } else if (component.containsGesture(possiblePan)) {
    ViewParent p;
    if ((p = component.getRealView().getParent()) != null) {
      p.requestDisallowInterceptTouchEvent(true);
    }
    if (mPendingPan != null) {
      handleMotionEvent(mPendingPan, e2);//finish pan if exist
    }
    mPendingPan = possiblePan;
    component.fireEvent(possiblePan.toString(), createFireEventParam(e2, CUR_EVENT, START));

    result = true;
  } else if (containsSimplePan()) {
    if (panDownTime != e1.getEventTime()) {
      panDownTime = e1.getEventTime();
      mPendingPan = HighLevelGesture.PAN_END;
      component.fireEvent(HighLevelGesture.PAN_START.toString(),
          createFireEventParam(e1, CUR_EVENT, null));
    } else {
      component.fireEvent(HighLevelGesture.PAN_MOVE.toString(),
          createFireEventParam(e2, CUR_EVENT, null));
    }
    result = true;
  } else if (component.containsGesture(HighLevelGesture.SWIPE)) {
    if (swipeDownTime != e1.getEventTime()) {
      swipeDownTime = e1.getEventTime();
      List<Map<String, Object>> list = createMultipleFireEventParam(e2, null);
      Map<String, Object> param = list.get(list.size() - 1);
      if (Math.abs(distanceX) > Math.abs(distanceY)) {
        param.put(GestureInfo.DIRECTION, distanceX > 0 ? LEFT : RIGHT);
      } else {
        param.put(GestureInfo.DIRECTION, distanceY > 0 ? UP : DOWN);
      }
      component.getInstance().fireEvent(component.getDomObject().getRef(),
          HighLevelGesture.SWIPE.toString(), param);
      result = true;
    }
  }
  return result;
}
 

开发者ID:erguotou520,
项目名称:weex-uikit,
代码行数:62,
代码来源:WXGesture.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)