下面列出了android.support.v4.view.ViewCompat#MEASURED_STATE_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);
}
public static int[] convertByteToColor(byte[] data) {
int size = data.length;
if (size == 0) {
return null;
}
int[] color = new int[(size / 4)];
int colorLen = color.length;
for (int i = 0; i < colorLen; i++) {
int blue = data[(i * 4) + 2] & 255;
color[i] = ((((data[i * 4] & 255) << 16) | ((data[(i * 4) + 1] & 255) << 8)) | blue) | ViewCompat.MEASURED_STATE_MASK;
}
return color;
}
private static boolean shouldHandleMeasuredWidthTooSmall(View view, PercentLayoutInfo info) {
int state = ViewCompat.getMeasuredWidthAndState(view) & ViewCompat.MEASURED_STATE_MASK;
if (info == null || info.widthPercent == null || info.mPreservedParams == null || state != 16777216 || info.widthPercent.percent < 0.0f || info.mPreservedParams.width != -2) {
return false;
}
return true;
}
private static boolean shouldHandleMeasuredWidthTooSmall(View view, PercentLayoutInfo info)
{
int state = ViewCompat.getMeasuredWidthAndState(view) & ViewCompat.MEASURED_STATE_MASK;
if (info == null || info.widthPercent == null)
{
return false;
}
return state == ViewCompat.MEASURED_STATE_TOO_SMALL && info.widthPercent.percent >= 0 &&
info.mPreservedParams.width == ViewGroup.LayoutParams.WRAP_CONTENT;
}
private static boolean shouldHandleMeasuredHeightTooSmall(View view, PercentLayoutInfo info)
{
int state = ViewCompat.getMeasuredHeightAndState(view) & ViewCompat.MEASURED_STATE_MASK;
if (info == null || info.heightPercent == null)
{
return false;
}
return state == ViewCompat.MEASURED_STATE_TOO_SMALL && info.heightPercent.percent >= 0 &&
info.mPreservedParams.height == ViewGroup.LayoutParams.WRAP_CONTENT;
}
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)};
}
private static int calculateStatusColor(@ColorInt int color, int alpha) {
float a = 1.0f - (((float) alpha) / 255.0f);
return ((ViewCompat.MEASURED_STATE_MASK | (((int) (((double) (((float) ((color >> 16) & 255)) * a)) + 0.5d)) << 16)) | (((int) (((double) (((float) ((color >> 8) & 255)) * a)) + 0.5d)) << 8)) | ((int) (((double) (((float) (color & 255)) * a)) + 0.5d));
}
private static boolean shouldHandleMeasuredHeightTooSmall(View view, PercentLayoutInfo info) {
if (info == null || info.heightPercent == null || info.mPreservedParams == null || (ViewCompat.getMeasuredHeightAndState(view) & ViewCompat.MEASURED_STATE_MASK) != 16777216 || info.heightPercent.percent < 0.0f || info.mPreservedParams.height != -2) {
return false;
}
return true;
}
private static int calculateStatusBarColor(int color, int alpha) {
float a = 1.0f - (((float) alpha) / 255.0f);
return ((ViewCompat.MEASURED_STATE_MASK | (((int) (((double) (((float) ((color >> 16) & 255)) * a)) + 0.5d)) << 16)) | (((int) (((double) (((float) ((color >> 8) & 255)) * a)) + 0.5d)) << 8)) | ((int) (((double) (((float) (color & 255)) * a)) + 0.5d));
}
private static boolean shouldHandleMeasuredWidthTooSmall(View view, PercentLayoutInfo info) {
int state = ViewCompat.getMeasuredWidthAndState(view) & ViewCompat.MEASURED_STATE_MASK;
return state == ViewCompat.MEASURED_STATE_TOO_SMALL && info.widthPercent >= 0 &&
info.mPreservedParams.width == ViewGroup.LayoutParams.WRAP_CONTENT;
}
private static boolean shouldHandleMeasuredHeightTooSmall(View view, PercentLayoutInfo info) {
int state = ViewCompat.getMeasuredHeightAndState(view) & ViewCompat.MEASURED_STATE_MASK;
return state == ViewCompat.MEASURED_STATE_TOO_SMALL && info.heightPercent >= 0 &&
info.mPreservedParams.height == ViewGroup.LayoutParams.WRAP_CONTENT;
}