diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-05-20 22:26:25 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-05-20 22:26:25 +0200 |
commit | ea44db4c633ba5ede5044aaa089819a817060d28 (patch) | |
tree | 214861fe6aeeb817b83b217c2a1b92c06239c494 /src/main/java/eu/siacs/conversations/ui/adapter | |
parent | 2da48b39b5605b174493cf4fa9c5232b63077de6 (diff) |
use glide as image loader and add a simple video preview
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/adapter')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index b671a6f43..8fe1d029a 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -485,6 +485,25 @@ public class MessageAdapter extends ArrayAdapter<Message> { viewHolder.image.setOnLongClickListener(openContextMenu); } + private void displayVideoMessage(ViewHolder viewHolder, + final Message message) { + viewHolder.aw_player.setVisibility(View.GONE); + if (viewHolder.download_button != null) { + viewHolder.download_button.setVisibility(View.GONE); + } + viewHolder.messageBody.setVisibility(View.GONE); + viewHolder.image.setVisibility(View.VISIBLE); + activity.loadVideoPreview(message, viewHolder.image); + viewHolder.image.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + openDownloadable(message); + } + }); + viewHolder.image.setOnLongClickListener(openContextMenu); + } + private void loadMoreMessages(Conversation conversation) { conversation.setLastClearHistory(0); conversation.setHasMessagesLeftOnServer(true); @@ -631,6 +650,7 @@ public class MessageAdapter extends ArrayAdapter<Message> { }); final Transferable transferable = message.getTransferable(); + String mimeType = message.getMimeType(); if (transferable != null && transferable.getStatus() != Transferable.STATUS_UPLOADING) { if (transferable.getStatus() == Transferable.STATUS_OFFER) { displayDownloadableMessage(viewHolder,message,activity.getString(R.string.download_x_file, UIHelper.getFileDescriptionString(activity, message))); @@ -645,10 +665,13 @@ public class MessageAdapter extends ArrayAdapter<Message> { if (message.getFileParams().width > 0) { displayImageMessage(viewHolder,message); } else { - String mimeType = message.getMimeType(); - if (mimeType != null) { - if (message.getMimeType().startsWith("audio/")) - displayAudioMessage(viewHolder, message, position); + if (mimeType != null) { + if (message.getMimeType().startsWith("audio/")) { + displayAudioMessage(viewHolder, message, position); + } else if (message.getMimeType().startsWith("video/")) { + displayVideoMessage(viewHolder, message); + //ToDo add overlay e.g. play button + } else displayOpenableMessage(viewHolder, message); } else displayOpenableMessage(viewHolder, message); } |