From: Andy Scherzinger Date: Fri, 11 Sep 2015 09:15:55 +0000 (+0200) Subject: further cleanup, moving folder icon determination into util class X-Git-Tag: oc-android-1.8~7^2~3 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/b1aff427156f28323f11b7fc1f2eba94326b118e?ds=inline;hp=--cc further cleanup, moving folder icon determination into util class --- b1aff427156f28323f11b7fc1f2eba94326b118e diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 75b27389..5e94e0f2 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -336,18 +336,9 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { } else { // Folder - - if (checkIfFileIsSharedWithMe(file)) { - fileIcon.setImageResource(R.drawable.shared_with_me_folder); - } else if (file.isShareByLink()) { - // If folder is sharedByLink, icon folder must be changed to - // folder-public one - fileIcon.setImageResource(R.drawable.folder_public); - } else { - fileIcon.setImageResource( - MimetypeIconUtil.getFileTypeIconId(file.getMimetype(), file.getFileName()) - ); - } + fileIcon.setImageResource( + MimetypeIconUtil.getFolderTypeIconId( + checkIfFileIsSharedWithMe(file), file.isShareByLink())); } } diff --git a/src/com/owncloud/android/utils/MimetypeIconUtil.java b/src/com/owncloud/android/utils/MimetypeIconUtil.java index e67479b3..2c7f6ee0 100644 --- a/src/com/owncloud/android/utils/MimetypeIconUtil.java +++ b/src/com/owncloud/android/utils/MimetypeIconUtil.java @@ -12,8 +12,8 @@ import java.util.List; import java.util.Map; /** - *

Helper class for detecting the right icon for a file or directory, - * based on its mime type and/or file extension.

+ *

Helper class for detecting the right icon for a file or folder, + * based on its mime type and file extension.

* * This class maintains all the necessary mappings fot these detections.
* 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