Fixed playback speed button

Problem was that a float 5.99999 was casted to an int and therefore was 5.
This commit is contained in:
ByteHamster 2019-11-12 17:12:05 +01:00
parent 60a070b56c
commit f63d8f9803
1 changed files with 9 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.TextView; import android.widget.TextView;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import java.util.Locale; import java.util.Locale;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.feed.util.PlaybackSpeedUtils; import de.danoeh.antennapod.core.feed.util.PlaybackSpeedUtils;
@ -42,7 +43,12 @@ public class PlaybackControlsDialog extends DialogFragment {
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
controller = new PlaybackController(getActivity(), false); controller = new PlaybackController(getActivity(), false) {
@Override
public void setupGUI() {
setupUi();
}
};
controller.init(); controller.init();
setupUi(); setupUi();
} }
@ -109,6 +115,7 @@ public class PlaybackControlsDialog extends DialogFragment {
controller.setPlaybackSpeed(playbackSpeed); controller.setPlaybackSpeed(playbackSpeed);
String speedPref = String.format(Locale.US, "%.2f", playbackSpeed); String speedPref = String.format(Locale.US, "%.2f", playbackSpeed);
PlaybackPreferences.setCurrentlyPlayingTemporaryPlaybackSpeed(playbackSpeed);
if (isPlayingVideo) { if (isPlayingVideo) {
UserPreferences.setVideoPlaybackSpeed(speedPref); UserPreferences.setVideoPlaybackSpeed(speedPref);
} else { } else {
@ -135,7 +142,7 @@ public class PlaybackControlsDialog extends DialogFragment {
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar) {
} }
}); });
barPlaybackSpeed.setProgress((int) ((currentSpeed - minPlaybackSpeed) / PLAYBACK_SPEED_STEP)); barPlaybackSpeed.setProgress(Math.round((currentSpeed - minPlaybackSpeed) / PLAYBACK_SPEED_STEP));
final SeekBar barLeftVolume = (SeekBar) dialog.findViewById(R.id.volume_left); final SeekBar barLeftVolume = (SeekBar) dialog.findViewById(R.id.volume_left);
barLeftVolume.setProgress(UserPreferences.getLeftVolumePercentage()); barLeftVolume.setProgress(UserPreferences.getLeftVolumePercentage());