本文整理汇总了Java中android.view.MotionEvent.PointerProperties类的典型用法代码示例。如果您正苦于以下问题:Java PointerProperties类的具体用法?Java PointerProperties怎么用?Java PointerProperties使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PointerProperties类属于android.view.MotionEvent包,在下文中一共展示了PointerProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyMovements
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
/**
* Applies all changes that were set via {@link #setMovement(int, float, float) the setMovement(...)} method.
*/
public void applyMovements() {
int pointerCount = pointerIds.size();
PointerCoords[] coords = new PointerCoords[pointerCount];
PointerProperties[] properties = new PointerProperties[pointerCount];
int i = 0;
for (Integer pointerId : pointerIds) {
coords[i] = pointerPositionsMap.get(pointerId);
properties[i] = pointerPropertiesMap.get(pointerId);
i++;
}
injectMultipointMotionEvent(coords, properties);
}
示例2: injectMultipointMotionEvent
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
private void injectMultipointMotionEvent(PointerCoords[] coords, PointerProperties[] properties) {
int pointerCount = coords.length;
long now = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(now, now, // when the event happened
MotionEvent.ACTION_MOVE, // event type
pointerCount, // number of pointers
properties, // pointer properties
coords, // pointer coordinate descriptors
DEFAULT_META_STATE,
0,
DEFAULT_PRECISION_X,
DEFAULT_PRECISION_Y,
DEVICE_ID,
DEFAULT_EDGE_FLAGS,
DEFAULT_INPUT_SOURCE,
0 // no flags
);
injectMethodFacade(event);
}
示例3: setPointer
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
@CalledByNative
void setPointer(int index, int x, int y, int id) {
assert (0 <= index && index < MAX_NUM_POINTERS);
// Convert coordinates from density independent pixels to density dependent pixels.
float scaleFactor = getDisplay().getDipScale();
PointerCoords coords = new PointerCoords();
coords.x = scaleFactor * x;
coords.y = scaleFactor * y;
coords.pressure = 1.0f;
mPointerCoords[index] = coords;
PointerProperties properties = new PointerProperties();
properties.id = id;
mPointerProperties[index] = properties;
}
示例4: TouchPointer
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
TouchPointer(int startX, int startY, int deltaX, int deltaY,
int id, float scale) {
mStartX = startX * scale;
mStartY = startY * scale;
mDeltaX = deltaX * scale;
mDeltaY = deltaY * scale;
if (deltaX != 0 || deltaY != 0) {
mStepX = mDeltaX / Math.abs(mDeltaX + mDeltaY);
mStepY = mDeltaY / Math.abs(mDeltaX + mDeltaY);
} else {
mStepX = 0;
mStepY = 0;
}
mProperties = new PointerProperties();
mProperties.id = id;
mProperties.toolType = MotionEvent.TOOL_TYPE_FINGER;
mCoords = new PointerCoords();
mCoords.x = mStartX;
mCoords.y = mStartY;
mCoords.pressure = 1.0f;
}
示例5: GenericTouchGesture
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
GenericTouchGesture(ContentViewCore contentViewCore,
int startX0, int startY0, int deltaX0, int deltaY0,
int startX1, int startY1, int deltaX1, int deltaY1) {
mContentViewCore = contentViewCore;
float scale = mContentViewCore.getRenderCoordinates().getDeviceScaleFactor();
mPointers = new TouchPointer[2];
mPointers[0] = new TouchPointer(startX0, startY0, deltaX0, deltaY0, 0, scale);
mPointers[1] = new TouchPointer(startX1, startY1, deltaX1, deltaY1, 1, scale);
mPointerProperties = new PointerProperties[2];
mPointerProperties[0] = mPointers[0].getProperties();
mPointerProperties[1] = mPointers[1].getProperties();
mPointerCoords = new PointerCoords[2];
mPointerCoords[0] = mPointers[0].getCoords();
mPointerCoords[1] = mPointers[1].getCoords();
}
示例6: GenericTouchGesture
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
GenericTouchGesture(ContentViewCore contentViewCore,
int startX, int startY, int deltaX, int deltaY) {
mContentViewCore = contentViewCore;
float scale = mContentViewCore.getRenderCoordinates().getDeviceScaleFactor();
int scaledTouchSlop = getScaledTouchSlop();
mPointers = new TouchPointer[1];
mPointers[0] = new TouchPointer(startX, startY, deltaX, deltaY, 0,
scale, scaledTouchSlop);
mPointerProperties = new PointerProperties[1];
mPointerProperties[0] = mPointers[0].getProperties();
mPointerCoords = new PointerCoords[1];
mPointerCoords[0] = mPointers[0].getCoords();
}
示例7: setPointer
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
@CalledByNative
void setPointer(int index, int x, int y, int id) {
assert (0 <= index && index < MAX_NUM_POINTERS);
// Convert coordinates from density independent pixels to density dependent pixels.
float scaleFactor = mContentViewCore.getRenderCoordinates().getDeviceScaleFactor();
PointerCoords coords = new PointerCoords();
coords.x = scaleFactor * x;
coords.y = scaleFactor * y;
coords.pressure = 1.0f;
mPointerCoords[index] = coords;
PointerProperties properties = new PointerProperties();
properties.id = id;
mPointerProperties[index] = properties;
}
示例8: injectFingerRegisterEvent
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
private void injectFingerRegisterEvent(int newPointerId) {
int pointerCount = pointerIds.size();
int action = pointerCount == 1 ? MotionEvent.ACTION_DOWN : MotionEvent.ACTION_POINTER_DOWN;
PointerCoords[] coords = new PointerCoords[pointerCount];
PointerProperties[] properties = new PointerProperties[pointerCount];
int i = 0;
for (Integer pointerId : pointerIds) {
coords[i] = pointerPositionsMap.get(pointerId);
properties[i] = pointerPropertiesMap.get(pointerId);
i++;
}
long now = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(now,
now,
action,
pointerCount,
properties,
coords,
DEFAULT_META_STATE,
0,
DEFAULT_PRECISION_X,
DEFAULT_PRECISION_Y,
DEVICE_ID,
DEFAULT_EDGE_FLAGS,
DEFAULT_INPUT_SOURCE,
0);
if (action == MotionEvent.ACTION_POINTER_DOWN) {
int newPointerIndex = event.findPointerIndex(newPointerId);
event.setAction(action | (newPointerIndex << MotionEvent.ACTION_POINTER_INDEX_SHIFT));
}
injectMethodFacade(event);
}
示例9: injectFingerUnregisterEvent
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
private void injectFingerUnregisterEvent(int upPointerId) {
int pointerCount = pointerIds.size();
int action = pointerCount == 1 ? MotionEvent.ACTION_UP : MotionEvent.ACTION_POINTER_UP;
PointerCoords[] coords = new PointerCoords[pointerCount];
PointerProperties[] properties = new PointerProperties[pointerCount];
int i = 0;
for (Integer pointerId : pointerIds) {
coords[i] = pointerPositionsMap.get(pointerId);
properties[i] = pointerPropertiesMap.get(pointerId);
if (upPointerId == pointerId) {
coords[i].pressure = 0.0f;
}
i++;
}
long now = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(now,
now,
action,
pointerCount,
properties,
coords,
DEFAULT_META_STATE,
0,
DEFAULT_PRECISION_X,
DEFAULT_PRECISION_Y,
DEVICE_ID,
DEFAULT_EDGE_FLAGS,
DEFAULT_INPUT_SOURCE,
0);
if (action == MotionEvent.ACTION_POINTER_UP) {
int newPointerIndex = event.findPointerIndex(upPointerId);
event.setAction(action | (newPointerIndex << MotionEvent.ACTION_POINTER_INDEX_SHIFT));
}
injectMethodFacade(event);
}
示例10: toMotionEventInputParams
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
private static MotionInputEventParams toMotionEventInputParams(
final int actionCode, final PointerCoords coordinates, final int button,
final PointerProperties properties, final long startDelta) {
final MotionInputEventParams evtParams = new MotionInputEventParams();
evtParams.actionCode = actionCode;
evtParams.coordinates = coordinates;
evtParams.button = button;
evtParams.properties = properties;
evtParams.startDelta = startDelta;
return evtParams;
}
示例11: filterPointerProperties
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
private static PointerProperties[] filterPointerProperties(
final List<MotionInputEventParams> motionEventsParams, final boolean shouldHovering) {
final List<PointerProperties> result = new ArrayList<>();
for (final MotionInputEventParams eventParams : motionEventsParams) {
if (shouldHovering && HOVERING_ACTIONS.contains(eventParams.actionCode)) {
result.add(eventParams.properties);
} else if (!shouldHovering && !HOVERING_ACTIONS.contains(eventParams.actionCode)) {
result.add(eventParams.properties);
}
}
return result.toArray(new PointerProperties[result.size()]);
}
示例12: c
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
final MotionEvent.PointerProperties c()
{
MotionEvent.PointerProperties localPointerProperties = new MotionEvent.PointerProperties();
localPointerProperties.toolType = 1;
localPointerProperties.id = this.b;
return localPointerProperties;
}
示例13: TouchPointer
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
TouchPointer(int startX, int startY, int deltaX, int deltaY,
int id, float scale, int scaledTouchSlop) {
mStartX = startX * scale;
mStartY = startY * scale;
float scaledDeltaX = deltaX * scale;
float scaledDeltaY = deltaY * scale;
if (scaledDeltaX != 0 || scaledDeltaY != 0) {
// The touch handler only considers a pointer as moving once
// it's been moved by more than scaledTouchSlop pixels. We
// thus increase the delta distance so the move is actually
// registered as covering the specified distance.
float distance = (float)Math.sqrt(scaledDeltaX * scaledDeltaX +
scaledDeltaY * scaledDeltaY);
mDeltaX = scaledDeltaX * (1 + scaledTouchSlop / distance);
mDeltaY = scaledDeltaY * (1 + scaledTouchSlop / distance);
}
else {
mDeltaX = scaledDeltaX;
mDeltaY = scaledDeltaY;
}
if (deltaX != 0 || deltaY != 0) {
mStepX = mDeltaX / Math.abs(mDeltaX + mDeltaY);
mStepY = mDeltaY / Math.abs(mDeltaX + mDeltaY);
} else {
mStepX = 0;
mStepY = 0;
}
mProperties = new PointerProperties();
mProperties.id = id;
mProperties.toolType = MotionEvent.TOOL_TYPE_FINGER;
mCoords = new PointerCoords();
mCoords.x = mStartX;
mCoords.y = mStartY;
mCoords.pressure = 1.0f;
}
示例14: readEmbeddedMotionEvent
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
private void readEmbeddedMotionEvent(final JsonReader jsonReader, final ReplayData replayData,
final int actionType) throws IOException {
jsonReader.beginObject();
PointerProperties[] pointerPropertiesArray = null;
while (jsonReader.hasNext()) { // pointerIds/xyt
final String name = jsonReader.nextName();
if (name.equals("pointerIds")) {
pointerPropertiesArray = readPointerProperties(jsonReader);
} else if (name.equals("xyt")) {
readPointerData(jsonReader, replayData, actionType, pointerPropertiesArray);
}
}
jsonReader.endObject();
}
示例15: readPointerProperties
import android.view.MotionEvent.PointerProperties; //导入依赖的package包/类
private PointerProperties[] readPointerProperties(final JsonReader jsonReader)
throws IOException {
final ArrayList<PointerProperties> pointerPropertiesArrayList =
new ArrayList<PointerProperties>();
jsonReader.beginArray();
while (jsonReader.hasNext()) {
final PointerProperties pointerProperties = new PointerProperties();
pointerProperties.id = jsonReader.nextInt();
pointerProperties.toolType = MotionEvent.TOOL_TYPE_UNKNOWN;
pointerPropertiesArrayList.add(pointerProperties);
}
jsonReader.endArray();
return pointerPropertiesArrayList.toArray(
new PointerProperties[pointerPropertiesArrayList.size()]);
}