From 4f67bf821ee554ddc47c4eec19751914111f9442 Mon Sep 17 00:00:00 2001 From: jhengazuki Date: Mon, 27 Oct 2025 16:47:44 +0800 Subject: [PATCH] Clean code --- .../main/java/com/fongmi/android/tv/utils/Util.java | 2 +- .../fongmi/android/tv/ui/custom/CustomKeyDown.java | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/fongmi/android/tv/utils/Util.java b/app/src/main/java/com/fongmi/android/tv/utils/Util.java index f35d8f328..3720eb993 100644 --- a/app/src/main/java/com/fongmi/android/tv/utils/Util.java +++ b/app/src/main/java/com/fongmi/android/tv/utils/Util.java @@ -78,7 +78,7 @@ public class Util { try { float value = activity.getWindow().getAttributes().screenBrightness; if (WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL >= value && value >= WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF) return value; - return Settings.System.getFloat(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS) / 128; + return Settings.System.getFloat(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS) / 255; } catch (Exception e) { return 0.5f; } diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDown.java b/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDown.java index ecfa1b093..83cda79f9 100644 --- a/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDown.java +++ b/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDown.java @@ -66,8 +66,8 @@ public class CustomKeyDown extends GestureDetector.SimpleOnGestureListener imple public void resetScale() { if (scale == 1.0f) return; videoView.animate().scaleX(1.0f).scaleY(1.0f).translationX(0f).translationY(0f).setDuration(250).withEndAction(() -> { - videoView.setPivotY(videoView.getHeight() / 2f); - videoView.setPivotX(videoView.getWidth() / 2f); + videoView.setPivotY(videoView.getHeight() / 2.0f); + videoView.setPivotX(videoView.getWidth() / 2.0f); scale = 1.0f; }).start(); } @@ -167,9 +167,8 @@ public class CustomKeyDown extends GestureDetector.SimpleOnGestureListener imple } private void setBright(float deltaY) { - if (bright == -1.0f) bright = 0.5f; int height = videoView.getMeasuredHeight(); - float brightness = deltaY * 2 / height + bright; + float brightness = deltaY * 2.0f / height + bright; if (brightness < 0) brightness = 0f; if (brightness > 1.0f) brightness = 1.0f; WindowManager.LayoutParams attributes = activity.getWindow().getAttributes(); @@ -181,12 +180,12 @@ public class CustomKeyDown extends GestureDetector.SimpleOnGestureListener imple private void setVolume(float deltaY) { int height = videoView.getMeasuredHeight(); int maxVolume = manager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); - float deltaV = deltaY * 2 / height * maxVolume; + float deltaV = deltaY * 2.0f / height * maxVolume; float index = volume + deltaV; if (index > maxVolume) index = maxVolume; if (index < 0) index = 0; manager.setStreamVolume(AudioManager.STREAM_MUSIC, (int) index, 0); - listener.onVolume((int) (index / maxVolume * 100)); + listener.onVolume((int) (index / maxVolume * 100.0f)); } @Override