小米手机获取了一个亮度900多,就会出现亮度计算错误
deltaY = -deltaY;
int deltaV = (int) (255 * deltaY * 3 / mScreenHeight);
WindowManager.LayoutParams params = JZUtils.getWindow(getContext()).getAttributes();
if (((mGestureDownBrightness + deltaV) / 255) >= 1) {//这和声音有区别,必须自己过滤一下负值
params.screenBrightness = 1;
} else if (((mGestureDownBrightness + deltaV) / 255) <= 0) {
params.screenBrightness = 0.01f;
} else {
params.screenBrightness = (mGestureDownBrightness + deltaV) / 255;
}
Log.e("Vera_亮度", "mGestureDownBrightness=" + mGestureDownBrightness);
int total = 255;
if (mGestureDownBrightness > 255) {
mGestureDownBrightness = mGestureDownBrightness * 255 / 2047;
}
JZUtils.getWindow(getContext()).setAttributes(params);
//dialog中显示百分比
int brightnessPercent = (int) (mGestureDownBrightness * 100 / 255 + deltaY * 3 * 100 / mScreenHeight);
showBrightnessDialog(brightnessPercent);
Log.e("Vera_亮度", "brightnessPercent=" + brightnessPercent);
网友评论