diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2015-07-19 10:35:28 +0200 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-07-19 10:35:28 +0200 |
commit | 76393e1e7c029ff5837b2210a9ef891b897df1b8 (patch) | |
tree | acdcfbefb8fecf3d4092633f752ec9197fbb2094 /core/src/main | |
parent | 35dcabd10398482fb5b06b72d81d3395d035fe70 (diff) | |
download | AntennaPod-76393e1e7c029ff5837b2210a9ef891b897df1b8.zip |
Info text has smaller font, conversion moved utility class
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/Converter.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java b/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java index a0b514bd6..917f99564 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/Converter.java @@ -1,7 +1,10 @@ package de.danoeh.antennapod.core.util; +import android.content.Context; import android.util.Log; +import de.danoeh.antennapod.core.R; + /** Provides methods for converting various units. */ public final class Converter { /** Class shall not be instantiated. */ @@ -99,5 +102,21 @@ public final class Converter { return Integer.valueOf(parts[0]) * 3600 * 1000 + Integer.valueOf(parts[1]) * 1000 * 60; } + + /** Converts milliseconds to a localized string containing hours and minutes */ + public static String getDurationStringLocalized(Context context, int duration) { + int h = duration / HOURS_MIL; + int rest = duration - h * HOURS_MIL; + int m = rest / MINUTES_MIL; + + String result = ""; + if(h > 0) { + String hours = context.getString(R.string.time_unit_hours); + result += h + " " + hours + " "; + } + String minutes = context.getString(R.string.time_unit_minutes); + result += m + " " + minutes; + return result; + } } |