From e5d82b325d3bd2f8d6ac9155fa6b73049ca195aa Mon Sep 17 00:00:00 2001 From: Mikunj Date: Tue, 17 Sep 2019 09:57:23 +1000 Subject: [PATCH] Fix GIFs --- .../securesms/linkpreview/LinkPreviewRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java b/src/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java index 0f03fbef77..6d6d0f4ba7 100644 --- a/src/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java +++ b/src/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java @@ -11,6 +11,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.resource.gif.GifDrawable; import com.bumptech.glide.request.FutureTarget; +import com.bumptech.glide.util.ByteBufferUtil; import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.attachments.Attachment; import org.thoughtcrime.securesms.attachments.UriAttachment; @@ -158,8 +159,7 @@ public class LinkPreviewRepository implements InjectableType { SignalExecutors.UNBOUNDED.execute(() -> { try { GifDrawable gif = future.get(); - byte[] bytes = new byte[gif.getBuffer().remaining()]; - gif.getBuffer().get(bytes); + byte[] bytes = ByteBufferUtil.toBytes(gif.getBuffer()); Uri uri = BlobProvider.getInstance().forData(bytes).createForSingleSessionInMemory(); Optional thumbnail = Optional.of(new UriAttachment(uri, uri, MediaUtil.IMAGE_GIF, AttachmentDatabase.TRANSFER_PROGRESS_DONE, bytes.length, gif.getIntrinsicWidth(), gif.getIntrinsicHeight(), null, null, false, false, null, null));