From 2c7fcbed60e849774370da212171bee4fe63d9ae Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Mon, 24 Oct 2016 13:51:34 -0700 Subject: [PATCH] Only load stills for low memory devices // FREEBIE --- .../securesms/giph/ui/GiphyAdapter.java | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/org/thoughtcrime/securesms/giph/ui/GiphyAdapter.java b/src/org/thoughtcrime/securesms/giph/ui/GiphyAdapter.java index 56cc21d288..b9739050d9 100644 --- a/src/org/thoughtcrime/securesms/giph/ui/GiphyAdapter.java +++ b/src/org/thoughtcrime/securesms/giph/ui/GiphyAdapter.java @@ -94,6 +94,11 @@ public class GiphyAdapter extends RecyclerView.Adapter images) { @@ -131,13 +136,23 @@ public class GiphyAdapter extends RecyclerView.Adapter thumbnailRequest = Glide.with(context) .load(image.getStillUrl()); - Glide.with(context) - .load(image.getGifUrl()) - .thumbnail(thumbnailRequest) - .placeholder(new ColorDrawable(Util.getRandomElement(MaterialColor.values()).toConversationColor(context))) - .diskCacheStrategy(DiskCacheStrategy.ALL) - .listener(holder) - .into(holder.thumbnail); + if (Util.isLowMemory(context)) { + Glide.with(context) + .load(image.getStillUrl()) + .placeholder(new ColorDrawable(Util.getRandomElement(MaterialColor.values()).toConversationColor(context))) + .diskCacheStrategy(DiskCacheStrategy.ALL) + .into(holder.thumbnail); + + holder.setModelReady(); + } else { + Glide.with(context) + .load(image.getGifUrl()) + .thumbnail(thumbnailRequest) + .placeholder(new ColorDrawable(Util.getRandomElement(MaterialColor.values()).toConversationColor(context))) + .diskCacheStrategy(DiskCacheStrategy.ALL) + .listener(holder) + .into(holder.thumbnail); + } } @Override