diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-09-23 16:54:13 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-09-23 16:54:13 +0200 |
commit | 032466bb9936099fa9164dd733bc264739edc7fb (patch) | |
tree | 179365e7fda28867e8b6289405f19da71fbf0ece /src/main/java/de | |
parent | 60820f3e14e8ea1d756641646f50bc2dc54de528 (diff) |
add icon for unknown file while keeping 'file' icon for documents
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MediaPreviewAdapter.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MediaPreviewAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MediaPreviewAdapter.java index c89ce6216..3d9bce508 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MediaPreviewAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MediaPreviewAdapter.java @@ -17,6 +17,7 @@ import android.widget.ImageView; import java.lang.ref.WeakReference; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.concurrent.RejectedExecutionException; @@ -29,6 +30,15 @@ import de.pixart.messenger.ui.util.StyledAttributes; public class MediaPreviewAdapter extends RecyclerView.Adapter<MediaPreviewAdapter.MediaPreviewViewHolder> { + private static final List<String> DOCUMENT_MIMES = Arrays.asList( + "application/pdf", + "application/vnd.oasis.opendocument.text", + "application/msword", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "text/x-tex", + "text/plain" + ); + private final ArrayList<Attachment> mediaPreviews = new ArrayList<>(); private final ConversationFragment conversationFragment; @@ -89,7 +99,7 @@ public class MediaPreviewAdapter extends RecyclerView.Adapter<MediaPreviewAdapte } else { final String mime = attachment.getMime(); if (mime == null) { - attr = R.attr.media_preview_file; + attr = R.attr.media_preview_unknown; } else if (mime.startsWith("audio/")) { attr = R.attr.media_preview_audio; } else if (mime.equals("text/calendar") || (mime.equals("text/x-vcalendar"))) { @@ -100,8 +110,10 @@ public class MediaPreviewAdapter extends RecyclerView.Adapter<MediaPreviewAdapte attr = R.attr.media_preview_app; } else if (mime.equals("application/zip") || mime.equals("application/rar")) { attr = R.attr.media_preview_archive; + } else if (DOCUMENT_MIMES.contains(mime)) { + attr = R.attr.media_preview_document; } else { - attr = R.attr.media_preview_file; + attr = R.attr.media_preview_unknown; } } holder.binding.mediaPreview.setImageDrawable(StyledAttributes.getDrawable(context, attr)); |