Created
January 19, 2017 07:47
-
-
Save wyon/48c5e6786b53755f80d850a8ef64dd55 to your computer and use it in GitHub Desktop.
printMotionEvent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static StringBuilder printMotionEvent(MotionEvent event, StringBuilder stringBuilder) { | |
if (stringBuilder == null) { | |
stringBuilder = new StringBuilder(); | |
} | |
stringBuilder.append("[RawAction:0x").append(Integer.toHexString(event.getAction())) | |
.append(""); | |
switch (event.getAction()) { | |
case MotionEvent.ACTION_DOWN: | |
stringBuilder.append("(down)"); | |
break; | |
case MotionEvent.ACTION_MOVE: | |
stringBuilder.append("(move)"); | |
break; | |
case MotionEvent.ACTION_UP: | |
stringBuilder.append("(up )"); | |
break; | |
default: | |
stringBuilder.append("(othe)"); | |
} | |
stringBuilder.append(']'); | |
int hSize = event.getHistorySize(); | |
int pCount = event.getPointerCount(); | |
stringBuilder.append("[HistorySize:").append(hSize).append(']'); | |
stringBuilder.append("[PointerCount:").append(pCount).append(']').append('\n'); | |
for (int h = 0; h < hSize; h++) { | |
stringBuilder.append("[historyEventTime:").append(event.getHistoricalEventTime(h)).append(']').append('\n'); | |
for (int i = 0; i < pCount; i++) { | |
stringBuilder.append("[pointId:").append(event.getPointerId(i)).append("][HistoricalX:") | |
.append(event.getHistoricalX(i, h)).append("][HistoricalY:") | |
.append(event.getHistoricalY(i, h)).append(']').append('\n'); | |
} | |
} | |
stringBuilder.append("[EventTime:").append(event.getEventTime()).append(']').append('\n'); | |
for (int i = 0; i < pCount; i++) { | |
stringBuilder.append("[pointId:").append(event.getPointerId(i)).append(']') | |
.append("[X:").append(event.getX(i)) | |
.append("][Y:").append(event.getY(i)).append(']').append('\n'); | |
} | |
return stringBuilder; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment