Fix. Some icons are not correct. Showed default file icon when there is not mimetype
[pub/Android/ownCloud.git] / src / com / owncloud / android / utils / DisplayUtils.java
index da81f53..ec311a0 100644 (file)
@@ -29,11 +29,11 @@ import java.util.Set;
 import android.annotation.TargetApi;\r
 import android.content.Context;\r
 import android.os.Build;\r
-import android.text.format.DateFormat;\r
 import android.text.format.DateUtils;\r
 \r
 import com.owncloud.android.MainApp;\r
 import com.owncloud.android.R;\r
+import com.owncloud.android.datamodel.OCFile;\r
 \r
 /**\r
  * A helper class for some string operations.\r
@@ -164,9 +164,12 @@ public class DisplayUtils {
      */\r
     public static int getResourceId(String mimetype, String filename) {\r
 \r
-        if (mimetype == null || "DIR".equals(mimetype)) {\r
+        if (mimetype == null) {\r
+            return R.drawable.file;\r
+\r
+        } else if ("DIR".equals(mimetype)) {\r
             return R.drawable.ic_menu_archive;\r
-            \r
+\r
         } else {\r
             String [] parts = mimetype.split("/");\r
             String type = parts[0];\r
@@ -318,6 +321,19 @@ public class DisplayUtils {
             }\r
         }\r
         \r
-        return dateString.toString().split(",")[0];
+        return dateString.toString().split(",")[0];\r
+    }\r
+\r
+    /**\r
+     * Update the passed path removing the last "/" if it is not the root folder\r
+     * @param path\r
+     */\r
+    public static String getPathWithoutLastSlash(String path) {\r
+\r
+        // Remove last slash from path\r
+        if (path.length() > 1 && path.charAt(path.length()-1) == OCFile.PATH_SEPARATOR.charAt(0)) {\r
+            path = path.substring(0, path.length()-1);\r
+        }\r
+        return path;\r
     }\r
 }\r