X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/e98fc8b141fed66cbdd265aaebd2cfa3affb68ac..0b217c465dbf124c0f20b17b48d49e715e00603e:/src/com/owncloud/android/utils/DisplayUtils.java diff --git a/src/com/owncloud/android/utils/DisplayUtils.java b/src/com/owncloud/android/utils/DisplayUtils.java index 32d90173..e22b6de8 100644 --- a/src/com/owncloud/android/utils/DisplayUtils.java +++ b/src/com/owncloud/android/utils/DisplayUtils.java @@ -26,6 +26,7 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Set; +import java.util.Vector; import android.annotation.TargetApi; import android.content.Context; @@ -51,6 +52,8 @@ public class DisplayUtils { private static final String[] sizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; + private final static Double THUMBNAIL_THRESHOLD = 0.5; + private static HashMap mimeType2HUmanReadable; static { mimeType2HUmanReadable = new HashMap(); @@ -228,7 +231,7 @@ public class DisplayUtils { /** * Converts Unix time to human readable format - * @param miliseconds that have passed since 01/01/1970 + * @param milliseconds that have passed since 01/01/1970 * @return The human readable time for the users locale */ public static String unixTimeToHumanReadable(long milliseconds) { @@ -340,4 +343,31 @@ public class DisplayUtils { } return path; } + + /** + * + * @param mFiles + * @return true: imageView, false: listView + */ + public static boolean decideViewLayout(Vector mFiles){ + // decide image vs. file view + double countImages = 0; + double countFiles = 0; + + for (OCFile file : mFiles){ + if (!file.isFolder()){ + countFiles++; + + if (file.isImage()){ + countImages++; + } + } + } + + if ((countImages / countFiles) >= THUMBNAIL_THRESHOLD){ + return true; + } else { + return false; + } + } }