forked from APIJSON/APIJSON-Demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputUtil.java
More file actions
42 lines (36 loc) · 1.45 KB
/
InputUtil.java
File metadata and controls
42 lines (36 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package apijson.demo;
import android.content.res.Configuration;
import android.view.KeyEvent;
import android.view.MotionEvent;
public class InputUtil {
public static String getActionName(int action) {
String s = StringUtil.getTrimedString(MotionEvent.actionToString(action));
return s.startsWith("ACTION_") ? s.substring("ACTION_".length()) : s;
// switch (action) {
// case MotionEvent.ACTION_DOWN:
// return "DOWN";
// case MotionEvent.ACTION_MOVE:
// return "MOVE";
// case MotionEvent.ACTION_SCROLL:
// return "SCROLL";
// case MotionEvent.ACTION_UP:
// return "UP";
// case MotionEvent.ACTION_MASK:
// return "MASK";
// case MotionEvent.ACTION_OUTSIDE:
// return "OUTSIDE";
// default:
// return "CANCEL";
// }
}
public static String getOrientationName(int orientation) {
return orientation == Configuration.ORIENTATION_LANDSCAPE ? "HORIZONTAL" : "VERTICAL";
}
public static String getKeyCodeName(int keyCode) {
String s = StringUtil.getTrimedString(KeyEvent.keyCodeToString(keyCode));
return s.startsWith("KEYCODE_") ? s.substring("KEYCODE_".length()) : s;
}
public static String getScanCodeName(int scanCode) {
return "" + scanCode; //它是 hardware key id KeyEvent.keyCodeToString(scanCode);
}
}