[Android] Fix casting in maths operations
Geoffrey Métais
git at videolan.org
Thu Jan 24 10:26:50 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 24 09:36:00 2019 +0100| [89e71b6b5d223ebcfb1769c2e5db299b56678247] | committer: Geoffrey Métais
Fix casting in maths operations
> https://code.videolan.org/videolan/vlc-android/commit/89e71b6b5d223ebcfb1769c2e5db299b56678247
---
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index cbbd9704b..3aade0408 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1313,22 +1313,21 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
*/
private void showInfoWithVerticalBar(String text, int duration, int barNewValue, int max) {
showInfo(text, duration);
- if (mVerticalBarProgress == null)
- return;
+ if (mVerticalBarProgress == null) return;
LinearLayout.LayoutParams layoutParams;
if (barNewValue <= 100) {
layoutParams = (LinearLayout.LayoutParams) mVerticalBarProgress.getLayoutParams();
- layoutParams.weight = barNewValue * 100 / max;
+ layoutParams.weight = barNewValue * 100 / (float)max;
mVerticalBarProgress.setLayoutParams(layoutParams);
layoutParams = (LinearLayout.LayoutParams) mVerticalBarBoostProgress.getLayoutParams();
layoutParams.weight = 0;
mVerticalBarBoostProgress.setLayoutParams(layoutParams);
} else {
layoutParams = (LinearLayout.LayoutParams) mVerticalBarProgress.getLayoutParams();
- layoutParams.weight = 100 * 100 / max;
+ layoutParams.weight = 100 * 100 / (float)max;
mVerticalBarProgress.setLayoutParams(layoutParams);
layoutParams = (LinearLayout.LayoutParams) mVerticalBarBoostProgress.getLayoutParams();
- layoutParams.weight = (barNewValue - 100) * 100 / max;
+ layoutParams.weight = (barNewValue - 100) * 100 / (float)max;
mVerticalBarBoostProgress.setLayoutParams(layoutParams);
}
mVerticalBar.setVisibility(View.VISIBLE);
@@ -1687,9 +1686,9 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, vol, AudioManager.FLAG_SHOW_UI);
} catch (RuntimeException ignored) {} //Some device won't allow us to change volume
}
- vol = Math.round(vol * 100 / mAudioMax);
+ vol = Math.round(vol * 100 / (float) mAudioMax);
} else {
- vol = Math.round(vol * 100 / mAudioMax);
+ vol = Math.round(vol * 100 / (float) mAudioMax);
mService.setVolume(Math.round(vol));
}
showInfoWithVerticalBar(getString(R.string.volume) + "\n" + Integer.toString(vol) + '%', 1000, vol, audioBoostEnabled ? 200 : 100);
More information about the Android
mailing list