diff options
author | stefan-niedermann <info@niedermann.it> | 2020-02-10 15:57:05 +0300 |
---|---|---|
committer | stefan-niedermann <info@niedermann.it> | 2020-02-10 15:57:22 +0300 |
commit | d1da6ddc489ddfa1116e3cf0909177872de05b93 (patch) | |
tree | 95060671b5e57a1645ad7bbc71d6d8f3f8523e81 | |
parent | 66e2693545530522f1e69e8c87249f5f9003f195 (diff) |
#211 Attachments 📎
Catch mimetype == null
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/DeckAppGlideModule.java | 9 | ||||
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/card/AttachmentAdapter.java | 26 |
2 files changed, 14 insertions, 21 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/DeckAppGlideModule.java b/app/src/main/java/it/niedermann/nextcloud/deck/DeckAppGlideModule.java deleted file mode 100644 index fb637624f..000000000 --- a/app/src/main/java/it/niedermann/nextcloud/deck/DeckAppGlideModule.java +++ /dev/null @@ -1,9 +0,0 @@ -package it.niedermann.nextcloud.deck; - -import com.bumptech.glide.annotation.GlideModule; -import com.bumptech.glide.module.AppGlideModule; - -@GlideModule -public class DeckAppGlideModule extends AppGlideModule { - // no psecial config (yet) -} diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/AttachmentAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/AttachmentAdapter.java index 7b3776778..279ecd5f9 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/AttachmentAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/AttachmentAdapter.java @@ -57,18 +57,20 @@ public class AttachmentAdapter extends RecyclerView.Adapter<AttachmentAdapter.At public void onBindViewHolder(@NonNull AttachmentViewHolder holder, int position) { Attachment attachment = attachments.get(position); holder.notSyncedYet.setVisibility(attachment.getStatusEnum() == DBStatus.UP_TO_DATE ? View.GONE : View.VISIBLE); - if (attachment.getMimetype().startsWith("image")) { - // TODO Glide is currently not yet able to use SSO and fails on authentication - String uri = account.getUrl() + "/index.php/apps/deck/cards/" + cardRemoteId + "/attachment/" + attachment.getId(); - Glide.with(context) - .load(uri) - .error(R.drawable.ic_image_grey600_24dp) - .into(holder.filetype); - holder.filetype.setImageResource(R.drawable.ic_image_grey600_24dp); - } else if (attachment.getMimetype().startsWith("audio")) { - holder.filetype.setImageResource(R.drawable.ic_music_note_grey600_24dp); - } else if (attachment.getMimetype().startsWith("video")) { - holder.filetype.setImageResource(R.drawable.ic_local_movies_grey600_24dp); + if (attachment.getMimetype() != null) { + if (attachment.getMimetype().startsWith("image")) { + // TODO Glide is currently not yet able to use SSO and fails on authentication + String uri = account.getUrl() + "/index.php/apps/deck/cards/" + cardRemoteId + "/attachment/" + attachment.getId(); + Glide.with(context) + .load(uri) + .error(R.drawable.ic_image_grey600_24dp) + .into(holder.filetype); + holder.filetype.setImageResource(R.drawable.ic_image_grey600_24dp); + } else if (attachment.getMimetype().startsWith("audio")) { + holder.filetype.setImageResource(R.drawable.ic_music_note_grey600_24dp); + } else if (attachment.getMimetype().startsWith("video")) { + holder.filetype.setImageResource(R.drawable.ic_local_movies_grey600_24dp); + } } holder.filename.setText(attachment.getBasename()); holder.filesize.setText(Formatter.formatFileSize(context, attachment.getFilesize())); |