diff --git a/src/org/thoughtcrime/securesms/components/ThumbnailView.java b/src/org/thoughtcrime/securesms/components/ThumbnailView.java index 9191d3ddf4..41e77c6c0a 100644 --- a/src/org/thoughtcrime/securesms/components/ThumbnailView.java +++ b/src/org/thoughtcrime/securesms/components/ThumbnailView.java @@ -21,7 +21,6 @@ import android.widget.ImageView; import com.bumptech.glide.DrawableTypeRequest; import com.bumptech.glide.GenericRequestBuilder; import com.bumptech.glide.Glide; -import com.bumptech.glide.load.resource.bitmap.CenterCrop; import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; import com.bumptech.glide.load.resource.drawable.GlideDrawable; import com.bumptech.glide.request.RequestListener; @@ -32,11 +31,11 @@ import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.jobs.PartProgressEvent; import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri; +import org.thoughtcrime.securesms.mms.RoundedCorners; import org.thoughtcrime.securesms.mms.Slide; import org.thoughtcrime.securesms.mms.SlideDeck; import org.thoughtcrime.securesms.util.FutureTaskListener; import org.thoughtcrime.securesms.util.ListenableFutureTask; -import org.thoughtcrime.securesms.mms.RoundedCorners; import org.thoughtcrime.securesms.util.Util; import de.greenrobot.event.EventBus; @@ -245,7 +244,8 @@ public class ThumbnailView extends FrameLayout { public void onSuccess(final SlideDeck slideDeck) { if (slideDeck == null) return; - final Slide slide = slideDeck.getThumbnailSlide(getContext()); + final Slide slide = slideDeck.getThumbnailSlide(); + if (slide != null) { Util.runOnMain(new Runnable() { @Override diff --git a/src/org/thoughtcrime/securesms/mms/SlideDeck.java b/src/org/thoughtcrime/securesms/mms/SlideDeck.java index 1eb5dadff1..794b63b895 100644 --- a/src/org/thoughtcrime/securesms/mms/SlideDeck.java +++ b/src/org/thoughtcrime/securesms/mms/SlideDeck.java @@ -18,6 +18,7 @@ package org.thoughtcrime.securesms.mms; import android.content.Context; import android.graphics.drawable.Drawable; +import android.support.annotation.Nullable; import android.util.Pair; import org.thoughtcrime.securesms.R; @@ -89,7 +90,7 @@ public class SlideDeck { return false; } - public Slide getThumbnailSlide(Context context) { + public @Nullable Slide getThumbnailSlide() { for (Slide slide : slides) { if (slide.hasImage()) { return slide; diff --git a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java index d8a329ce7b..3fc256eec1 100644 --- a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java +++ b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java @@ -21,6 +21,7 @@ import com.bumptech.glide.Glide; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader; +import org.thoughtcrime.securesms.mms.Slide; import org.thoughtcrime.securesms.mms.SlideDeck; import org.thoughtcrime.securesms.preferences.NotificationPrivacyPreference; import org.thoughtcrime.securesms.recipients.Recipient; @@ -167,12 +168,17 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil private boolean hasBigPictureSlide(@Nullable ListenableFutureTask slideDeck) { try { - return masterSecret != null && - slideDeck != null && - Build.VERSION.SDK_INT >= 16 && - slideDeck.get().getThumbnailSlide(context).hasImage() && - !slideDeck.get().getThumbnailSlide(context).isInProgress() && - slideDeck.get().getThumbnailSlide(context).getThumbnailUri() != null; + if (masterSecret == null || slideDeck == null || Build.VERSION.SDK_INT < 16) { + return false; + } + + Slide thumbnailSlide = slideDeck.get().getThumbnailSlide(); + + return thumbnailSlide != null && + thumbnailSlide.hasImage() && + !thumbnailSlide.isInProgress() && + thumbnailSlide.getThumbnailUri() != null; + } catch (InterruptedException | ExecutionException e) { Log.w(TAG, e); return false; @@ -183,7 +189,7 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil @NonNull ListenableFutureTask slideDeck) { try { - Uri uri = slideDeck.get().getThumbnailSlide(context).getThumbnailUri(); + Uri uri = slideDeck.get().getThumbnailSlide().getThumbnailUri(); return Glide.with(context) .load(new DecryptableStreamUriLoader.DecryptableUri(masterSecret, uri))