further cleanup, moving folder icon determination into util class
authorAndy Scherzinger <info@andy-scherzinger.de>
Fri, 11 Sep 2015 09:15:55 +0000 (11:15 +0200)
committerAndy Scherzinger <info@andy-scherzinger.de>
Fri, 11 Sep 2015 09:15:55 +0000 (11:15 +0200)
src/com/owncloud/android/ui/adapter/FileListListAdapter.java
src/com/owncloud/android/utils/MimetypeIconUtil.java

index 75b2738..5e94e0f 100644 (file)
@@ -336,18 +336,9 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
 \r
             } else {\r
                 // Folder\r
-\r
-                if (checkIfFileIsSharedWithMe(file)) {\r
-                    fileIcon.setImageResource(R.drawable.shared_with_me_folder);\r
-                } else if (file.isShareByLink()) {\r
-                    // If folder is sharedByLink, icon folder must be changed to\r
-                    // folder-public one\r
-                    fileIcon.setImageResource(R.drawable.folder_public);\r
-                } else {\r
-                    fileIcon.setImageResource(\r
-                            MimetypeIconUtil.getFileTypeIconId(file.getMimetype(), file.getFileName())\r
-                    );\r
-                }\r
+                fileIcon.setImageResource(\r
+                        MimetypeIconUtil.getFolderTypeIconId(\r
+                                checkIfFileIsSharedWithMe(file), file.isShareByLink()));\r
             }\r
         }\r
 \r
index e67479b..2c7f6ee 100644 (file)
@@ -12,8 +12,8 @@ import java.util.List;
 import java.util.Map;
 
 /**
- * <p>Helper class for detecting the right icon for a file or directory,
- * based on its mime type and/or file extension.</p>
+ * <p>Helper class for detecting the right icon for a file or folder,
+ * based on its mime type and file extension.</p>
  *
  * This class maintains all the necessary mappings fot these detections.<br/>
  * In order to add further mappings, there are up to three look up maps that need further values:
@@ -67,6 +67,23 @@ public class MimetypeIconUtil {
     }
 
     /**
+     * Returns the resource identifier of an image to use as icon associated to a type of folder.
+     *
+     * @param isSharedWithUser flag if the folder is shared with the user
+     * @param isShareByLink flag if the folder is shared by link
+     * @return Identifier of an image resource.
+     */
+    public static int getFolderTypeIconId(boolean isSharedWithUser, boolean isShareByLink) {
+        if (isSharedWithUser) {
+            return R.drawable.shared_with_me_folder;
+        } else if (isShareByLink) {
+            return R.drawable.folder_public;
+        }
+
+        return R.drawable.ic_menu_archive;
+    }
+
+    /**
      * determines the icon based on the mime type.
      *
      * @param mimetypes the mimetypes