diff options
author | steckbrief <steckbrief@chefmail.de> | 2015-10-04 14:55:15 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2015-10-04 15:24:44 +0200 |
commit | 52aa81e82e57a2c1d0074d482e8e706960492b8a (patch) | |
tree | 26c21b35f4b70f840693877a782514498ce94db0 /src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java | |
parent | a3d62e6a10df307786079a2cc1f93eee591f96c5 (diff) |
Implements FS#72, FS#72, FS#73, FS#65, FS#66 - Resource List Dialog added, Open resource
list on long click in conversations overview, open resource list on click
on bare jid in contact details view, Message details dialog added
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java b/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java index 0ef07808..532ff1cb 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java @@ -1,5 +1,7 @@ package de.thedevstack.conversationsplus.utils; +import java.math.BigDecimal; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.Arrays; import java.net.URLConnection; @@ -286,4 +288,20 @@ public class UIHelper { body = body.replace("?","").replace("¿",""); return LOCATION_QUESTIONS.contains(body); } + + public static String getHumanReadableFileSize(long filesize) { + if (0 > filesize) { + return "?"; + } + double size = Double.valueOf(filesize); + String[] sizes = {" bytes", " Kb", " Mb", " Gb", " Tb"}; + int i = 0; + while (1023 < size) { + size /= 1024d; + ++i; + } + BigDecimal readableSize = new BigDecimal(size); + readableSize = readableSize.setScale(2, BigDecimal.ROUND_HALF_UP); + return readableSize.doubleValue() + sizes[i]; + } } |