下面列出了android.support.v4.view.MotionEventCompat#ACTION_POINTER_INDEX_MASK 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static int YUV2RGB(int y, int u, int v) {
u -= 128;
v -= 128;
int y1192 = (y + -16 < 0 ? 0 : y - 16) * 1192;
int r = y1192 + (v * 1634);
int g = (y1192 - (v * 833)) - (u * 400);
int b = y1192 + (u * 2066);
if (r > kMaxChannelValue) {
r = kMaxChannelValue;
} else if (r < 0) {
r = 0;
}
if (g > kMaxChannelValue) {
g = kMaxChannelValue;
} else if (g < 0) {
g = 0;
}
if (b > kMaxChannelValue) {
b = kMaxChannelValue;
} else if (b < 0) {
b = 0;
}
return ((ViewCompat.MEASURED_STATE_MASK | ((r << 6) & 16711680)) | ((g >> 2) & MotionEventCompat.ACTION_POINTER_INDEX_MASK)) | ((b >> 10) & 255);
}
private void onSecondaryPointerUp(MotionEvent ev) {
final int pointerIndex = (ev.getAction() & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >>
MotionEventCompat.ACTION_POINTER_INDEX_SHIFT;
final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
if (pointerId == mActivePointerId) {
// This was our active pointer going up. Choose a new
// active pointer and adjust accordingly.
// TODO: Make this decision more intelligent.
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mLastMotionY = (int) MotionEventCompat.getY(ev, newPointerIndex);
mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
if (mVelocityTracker != null) {
mVelocityTracker.clear();
}
}
}
private void onSecondaryPointerUp(MotionEvent ev) {
final int pointerIndex = (ev.getAction() & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >>
MotionEventCompat.ACTION_POINTER_INDEX_SHIFT;
final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
if (pointerId == mActivePointerId) {
// This was our active pointer going up. Choose a new
// active pointer and adjust accordingly.
// TODO: Make this decision more intelligent.
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mLastMotionY = (int) MotionEventCompat.getY(ev, newPointerIndex);
mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
if (mVelocityTracker != null) {
mVelocityTracker.clear();
}
}
}
private void onSecondaryPointerUp(MotionEvent event) {
final int pointerIndex = (event.getAction() &
MotionEventCompat.ACTION_POINTER_INDEX_MASK) >>
MotionEventCompat.ACTION_POINTER_INDEX_SHIFT;
final int pointerId = event.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
// This was our active pointer going up. Choose a new
// active pointer and adjust accordingly.
// TODO: Make this decision more intelligent.
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mMotionX = (int) event.getX(newPointerIndex);
mMotionY = (int) event.getY(newPointerIndex);
mActivePointerId = event.getPointerId(newPointerIndex);
recycleVelocityTracker();
}
}
private void onSecondaryPointerUp(MotionEvent event) {
final int pointerIndex = (event.getAction() &
MotionEventCompat.ACTION_POINTER_INDEX_MASK) >>
MotionEventCompat.ACTION_POINTER_INDEX_SHIFT;
final int pointerId = event.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
// This was our active pointer going up. Choose a new
// active pointer and adjust accordingly.
// TODO: Make this decision more intelligent.
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mMotionX = (int) event.getX(newPointerIndex);
mMotionY = (int) event.getY(newPointerIndex);
mActivePointerId = event.getPointerId(newPointerIndex);
recycleVelocityTracker();
}
}
public X8SendCmd setSyncTimeCmd() {
Calendar calendar = Calendar.getInstance();
short year = (short) calendar.get(1);
byte month = (byte) (calendar.get(2) + 1);
byte day = (byte) calendar.get(5);
byte hour = (byte) calendar.get(11);
byte min = (byte) calendar.get(12);
byte second = (byte) calendar.get(13);
X8SendCmd sendCmd = getFCBase((byte) X8S_Module.MODULE_FC.ordinal(), 0);
byte[] payload = new byte[11];
int i = 0 + 1;
payload[0] = (byte) 8;
int i2 = i + 1;
payload[i] = (byte) 4;
i = i2 + 1;
payload[i2] = (byte) 0;
i2 = i + 1;
payload[i] = (byte) 0;
i = i2 + 1;
payload[i2] = (byte) (year & 255);
i2 = i + 1;
payload[i] = (byte) ((MotionEventCompat.ACTION_POINTER_INDEX_MASK & year) >> 8);
i = i2 + 1;
payload[i2] = month;
i2 = i + 1;
payload[i] = day;
i = i2 + 1;
payload[i2] = hour;
i2 = i + 1;
payload[i] = min;
i = i2 + 1;
payload[i2] = second;
sendCmd.setPayLoad(payload);
sendCmd.packSendCmd();
return sendCmd;
}
public static byte[] decode(String code) {
if (code == null) {
return null;
}
int len = code.length();
if (len % 4 != 0) {
throw new IllegalArgumentException("Base64 string length must be 4*n");
} else if (code.length() == 0) {
return new byte[0];
} else {
int pad = 0;
if (code.charAt(len - 1) == LetvUtils.CHARACTER_EQUAL) {
pad = 0 + 1;
}
if (code.charAt(len - 2) == LetvUtils.CHARACTER_EQUAL) {
pad++;
}
int retLen = ((len / 4) * 3) - pad;
byte[] ret = new byte[retLen];
for (int i = 0; i < len; i += 4) {
int j = (i / 4) * 3;
int tmp = (((_$6699[code.charAt(i)] << 18) | (_$6699[code.charAt(i + 1)] << 12)) | (_$6699[code.charAt(i + 2)] << 6)) | _$6699[code.charAt(i + 3)];
ret[j] = (byte) ((16711680 & tmp) >> 16);
if (i < len - 4) {
ret[j + 1] = (byte) ((tmp & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >> 8);
ret[j + 2] = (byte) (tmp & 255);
} else {
if (j + 1 < retLen) {
ret[j + 1] = (byte) ((tmp & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >> 8);
}
if (j + 2 < retLen) {
ret[j + 2] = (byte) (tmp & 255);
}
}
}
return ret;
}
}
public void setBarrageBackgroundColor(int alpha, int color) {
if (alpha < 0) {
alpha = 0;
}
int b = color & 255;
int g = (MotionEventCompat.ACTION_POINTER_INDEX_MASK & color) >> 8;
int r = (16711680 & color) >> 16;
LogInfo.log("fornia", "直播弹幕信息 r" + r + "|g" + g + "|b" + b);
setBackgroundColor(Color.argb(alpha, r, g, b));
}
public static float[] cmykFromRgb(int rgbColor) {
int red = (16711680 & rgbColor) >> 16;
int green = (MotionEventCompat.ACTION_POINTER_INDEX_MASK & rgbColor) >> 8;
int blue = rgbColor & 255;
float black = Math.min(1.0f - (((float) red) / 255.0f), Math.min(1.0f - (((float) green) / 255.0f), 1.0f - (((float) blue) / 255.0f)));
float cyan = 1.0f;
float magenta = 1.0f;
float yellow = 1.0f;
if (black != 1.0f) {
cyan = ((1.0f - (((float) red) / 255.0f)) - black) / (1.0f - black);
magenta = ((1.0f - (((float) green) / 255.0f)) - black) / (1.0f - black);
yellow = ((1.0f - (((float) blue) / 255.0f)) - black) / (1.0f - black);
}
return new float[]{cyan, magenta, yellow, black};
}
private void onSecondaryPointerUp(MotionEvent ev) {
int pointerIndex = (ev.getAction() & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >> 8;
if (ev.getPointerId(pointerIndex) == this.mActivePointerId) {
int newPointerIndex = pointerIndex == 0 ? 1 : 0;
this.mMotionX = (int) ev.getX(newPointerIndex);
this.mMotionY = (int) ev.getY(newPointerIndex);
this.mMotionCorrection = 0;
this.mActivePointerId = ev.getPointerId(newPointerIndex);
}
}
private void onSecondaryPointerUp(MotionEvent ev) {
int pointerIndex = (ev.getAction() & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >> 8;
if (MotionEventCompat.getPointerId(ev, pointerIndex) == this.mActivePointerId) {
int newPointerIndex = pointerIndex == 0 ? 1 : 0;
this.mLastMotionY = (int) MotionEventCompat.getY(ev, newPointerIndex);
this.mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
if (this.mVelocityTracker != null) {
this.mVelocityTracker.clear();
}
}
}
private void onSecondaryPointerUp(MotionEvent ev) {
final int pointerIndex = (ev.getAction() & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >>
MotionEventCompat.ACTION_POINTER_INDEX_SHIFT;
final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
if (pointerId == mActivePointerId) {
// This was our active pointer going up. Choose getDirection new
// active pointer and adjust accordingly.
// TODO: Make this decision more intelligent.
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
if (mVelocityTracker != null) {
mVelocityTracker.clear();
}
}
}
private void onSecondaryPointerUp(MotionEvent event) {
final int pointerIndex = (event.getAction() & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >> MotionEventCompat.ACTION_POINTER_INDEX_SHIFT;
final int pointerId = event.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
// This was our active pointer going up. Choose a new
// active pointer and adjust accordingly.
// TODO: Make this decision more intelligent.
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mMotionX = (int) event.getX(newPointerIndex);
mMotionY = (int) event.getY(newPointerIndex);
mActivePointerId = event.getPointerId(newPointerIndex);
recycleVelocityTracker();
}
}
private void onSecondaryPointerUp(MotionEvent ev) {
final int pointerIndex = (ev.getAction() & MotionEventCompat.ACTION_POINTER_INDEX_MASK)
>> MotionEventCompat.ACTION_POINTER_INDEX_SHIFT;
final int pointerId = ev.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mLastMotionY = (int) ev.getY(newPointerIndex);
mActivePointerId = ev.getPointerId(newPointerIndex);
if (mVelocityTracker != null) {
mVelocityTracker.clear();
}
}
}
public static byte[] getBytes(float data) {
int intBits = Float.floatToIntBits(data);
return new byte[]{(byte) (intBits & 255), (byte) ((MotionEventCompat.ACTION_POINTER_INDEX_MASK & intBits) >> 8), (byte) ((16711680 & intBits) >> 16), (byte) ((ViewCompat.MEASURED_STATE_MASK & intBits) >> 24)};
}
public X8MediaCmd downMediaFile(int offset, short maxLen, String downFileName, boolean isStop) {
int i;
int i2;
X8MediaCmd x8MediaCmd = createBaseComand();
short len = (short) downFileName.getBytes().length;
byte[] nameBytes = downFileName.getBytes();
byte[] payload = new byte[(len + 13)];
byte[] lenBytes = ByteHexHelper.intToByteArray(payload.length);
if (isStop) {
i = 0 + 1;
payload[0] = (byte) 2;
i2 = i;
} else {
i = 0 + 1;
payload[0] = (byte) 1;
i2 = i;
}
System.arraycopy(lenBytes, 0, payload, i2, lenBytes.length);
i2 = lenBytes.length + 1;
byte[] offeBytes = ByteHexHelper.intToByteArray(offset);
System.arraycopy(offeBytes, 0, payload, i2, offeBytes.length);
i2 += offeBytes.length;
if (maxLen >= NTLMConstants.TARGET_INFORMATION_SUBBLOCK_DNS_DOMAIN_NAME_TYPE) {
maxLen = NTLMConstants.TARGET_INFORMATION_SUBBLOCK_DNS_DOMAIN_NAME_TYPE;
}
i = i2 + 1;
payload[i2] = (byte) (maxLen & 255);
i2 = i + 1;
payload[i] = (byte) ((MotionEventCompat.ACTION_POINTER_INDEX_MASK & maxLen) >> 8);
i = i2 + 1;
payload[i2] = (byte) (len & 255);
i2 = i + 1;
payload[i] = (byte) ((MotionEventCompat.ACTION_POINTER_INDEX_MASK & len) >> 8);
System.arraycopy(nameBytes, 0, payload, i2, nameBytes.length);
x8MediaCmd.setUsbCmdKey(offset);
x8MediaCmd.setFileOffset(offset);
x8MediaCmd.setReSendNum(5);
x8MediaCmd.setOutTime(1000);
x8MediaCmd.packCmd(payload);
return x8MediaCmd;
}
public X8MediaCmd downMediaFile2(int offset, short maxLen, String downFileName) {
X8MediaCmd x8MediaCmd = createBaseComand();
short len = (short) downFileName.getBytes().length;
byte[] nameBytes = downFileName.getBytes();
byte[] payload = new byte[(len + 13)];
int i = 0 + 1;
payload[0] = (byte) 1;
int payLoadLen = payload.length;
int i2 = i + 1;
payload[i] = (byte) (payLoadLen & 255);
i = i2 + 1;
payload[i2] = (byte) ((payLoadLen >> 8) & 255);
i2 = i + 1;
payload[i] = (byte) ((payLoadLen >> 16) & 255);
i = i2 + 1;
payload[i2] = (byte) ((payLoadLen >> 24) & 255);
i2 = i + 1;
payload[i] = (byte) (offset & 255);
i = i2 + 1;
payload[i2] = (byte) ((offset >> 8) & 255);
i2 = i + 1;
payload[i] = (byte) ((offset >> 16) & 255);
i = i2 + 1;
payload[i2] = (byte) ((offset >> 24) & 255);
if (maxLen >= NTLMConstants.TARGET_INFORMATION_SUBBLOCK_DNS_DOMAIN_NAME_TYPE) {
maxLen = NTLMConstants.TARGET_INFORMATION_SUBBLOCK_DNS_DOMAIN_NAME_TYPE;
}
i2 = i + 1;
payload[i] = (byte) (maxLen & 255);
i = i2 + 1;
payload[i2] = (byte) ((maxLen & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >> 8);
i2 = i + 1;
payload[i] = (byte) (len & 255);
i = i2 + 1;
payload[i2] = (byte) ((len & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >> 8);
System.arraycopy(nameBytes, 0, payload, i, nameBytes.length);
x8MediaCmd.setReSendNum(5);
x8MediaCmd.setOutTime(1000);
x8MediaCmd.packCmd(payload);
return x8MediaCmd;
}
public ZipLong(byte[] bArr, int i) {
this.a = ((long) (bArr[i + 3] << 24)) & 4278190080L;
this.a += (long) ((bArr[i + 2] << 16) & 16711680);
this.a += (long) ((bArr[i + 1] << 8) & MotionEventCompat.ACTION_POINTER_INDEX_MASK);
this.a += (long) (bArr[i] & 255);
}
public ZipShort(byte[] bArr, int i) {
this.a = (bArr[i + 1] << 8) & MotionEventCompat.ACTION_POINTER_INDEX_MASK;
this.a += bArr[i] & 255;
}
public byte[] getBytes() {
return new byte[]{(byte) (this.a & 255), (byte) ((this.a & MotionEventCompat.ACTION_POINTER_INDEX_MASK) >> 8)};
}