diff options
author | Cédric Cabessa <ced@ryick.net> | 2019-03-03 18:35:52 +0100 |
---|---|---|
committer | Cédric Cabessa <ced@ryick.net> | 2019-04-28 21:03:18 +0200 |
commit | 6187945e8f82dc36bdbc3a86e9723569107522d5 (patch) | |
tree | 2a47ee097e149b8aabd8f2739ecb6afb58b73555 /core | |
parent | 743ec1927c8abc2506b4a02264712313efc695b7 (diff) | |
download | AntennaPod-6187945e8f82dc36bdbc3a86e9723569107522d5.zip |
add a time conversion class
convert time depending on current playback speed and preferences
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java b/core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java new file mode 100644 index 000000000..5fea8238b --- /dev/null +++ b/core/src/main/java/de/danoeh/antennapod/core/util/TimeSpeedConverter.java @@ -0,0 +1,22 @@ +package de.danoeh.antennapod.core.util; + +import de.danoeh.antennapod.core.preferences.UserPreferences; + +public class TimeSpeedConverter { + private TimeSpeedConverter() { + + } + + /** Convert millisecond according to the current playback speed + * @param time: time to convert + * @return converted time (can be < 0 if time is < 0) + */ + public static int convert(int time) { + boolean timeRespectsSpeed = UserPreferences.timeRespectsSpeed(); + if (time > 0 && timeRespectsSpeed) { + float speed = Float.parseFloat(UserPreferences.getPlaybackSpeed()); + return (int)(time / speed); + } + return time; + } +} |