diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2020-04-12 23:52:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-12 23:52:29 +0200 |
commit | 04019931e0154a7765517f605753fe83db2d99d1 (patch) | |
tree | 27454259c42b686bf7ea75f63748de3b446d749d /core/src | |
parent | 95d74933ebdb3749bc750e2866f67e1221f34996 (diff) | |
parent | 30d3619d057b10f0be37e118232389eb804b1e19 (diff) | |
download | AntennaPod-04019931e0154a7765517f605753fe83db2d99d1.zip |
Merge pull request #4047 from ebraminio/file-size-format
Use Android's own file size formatter
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/Converter.java | 44 |
1 files changed, 0 insertions, 44 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 6ecca941a..4e7e6a6b6 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,6 @@ package de.danoeh.antennapod.core.util; import android.content.Context; -import android.util.Log; import java.util.Locale; @@ -15,53 +14,10 @@ public final class Converter { /** Logging tag. */ private static final String TAG = "Converter"; - - - /** Indicates that the value is in the Byte range.*/ - private static final int B_RANGE = 0; - /** Indicates that the value is in the Kilobyte range.*/ - private static final int KB_RANGE = 1; - /** Indicates that the value is in the Megabyte range.*/ - private static final int MB_RANGE = 2; - /** Indicates that the value is in the Gigabyte range.*/ - private static final int GB_RANGE = 3; - /** Determines the length of the number for best readability.*/ - private static final int NUM_LENGTH = 1024; private static final int HOURS_MIL = 3600000; private static final int MINUTES_MIL = 60000; private static final int SECONDS_MIL = 1000; - - /** Takes a byte-value and converts it into a more readable - * String. - * @param input The value to convert - * @return The converted String with a unit - * */ - public static String byteToString(final long input) { - int i = 0; - int result = 0; - - for (i = 0; i < GB_RANGE + 1; i++) { - result = (int) (input / Math.pow(1024, i)); - if (result < NUM_LENGTH) { - break; - } - } - - switch (i) { - case B_RANGE: - return result + " B"; - case KB_RANGE: - return result + " KB"; - case MB_RANGE: - return result + " MB"; - case GB_RANGE: - return result + " GB"; - default: - Log.e(TAG, "Error happened in byteToString"); - return "ERROR"; - } - } /** Converts milliseconds to a string containing hours, minutes and seconds */ public static String getDurationStringLong(int duration) { |