diff --git a/src/org/thoughtcrime/securesms/components/ThumbnailView.java b/src/org/thoughtcrime/securesms/components/ThumbnailView.java index b9a412c7c52..be2faf1971c 100644 --- a/src/org/thoughtcrime/securesms/components/ThumbnailView.java +++ b/src/org/thoughtcrime/securesms/components/ThumbnailView.java @@ -160,9 +160,10 @@ private boolean isContextValid() { } private GenericRequestBuilder buildThumbnailGlideRequest(@NonNull Slide slide, @NonNull MasterSecret masterSecret) { + @SuppressWarnings("ConstantConditions") DrawableRequestBuilder builder = Glide.with(getContext()).load(new DecryptableUri(masterSecret, slide.getThumbnailUri())) - .crossFade() - .transform(new RoundedCorners(getContext(), true, radius, backgroundColorHint)); + .crossFade() + .transform(new RoundedCorners(getContext(), true, radius, backgroundColorHint)); if (slide.isInProgress()) return builder; else return builder.error(R.drawable.ic_missing_thumbnail_picture); diff --git a/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java b/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java index 7dae60b7942..b2f5618e6d8 100644 --- a/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java +++ b/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java @@ -129,7 +129,7 @@ public AttachmentDatabase(Context context, SQLiteOpenHelper databaseHelper) { try { InputStream generatedStream = thumbnailExecutor.submit(new ThumbnailFetchCallable(masterSecret, attachmentId)).get(); - if (generatedStream == null) throw new IOException("No thumbnail stream available: " + attachmentId); + if (generatedStream == null) throw new FileNotFoundException("No thumbnail stream available: " + attachmentId); else return generatedStream; } catch (InterruptedException ie) { throw new AssertionError("interrupted"); diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentStreamUriLoader.java b/src/org/thoughtcrime/securesms/mms/AttachmentStreamUriLoader.java index 1c8abdb6cdb..2db01844a0d 100644 --- a/src/org/thoughtcrime/securesms/mms/AttachmentStreamUriLoader.java +++ b/src/org/thoughtcrime/securesms/mms/AttachmentStreamUriLoader.java @@ -2,6 +2,7 @@ import android.content.Context; import android.net.Uri; +import android.support.annotation.NonNull; import com.bumptech.glide.load.data.DataFetcher; import com.bumptech.glide.load.model.GenericLoaderFactory; @@ -51,13 +52,29 @@ public DataFetcher getResourceFetcher(AttachmentModel model, int wi } public static class AttachmentModel { - public File attachment; - public byte[] key; + public @NonNull File attachment; + public @NonNull byte[] key; - public AttachmentModel(File attachment, byte[] key) { + public AttachmentModel(@NonNull File attachment, @NonNull byte[] key) { this.attachment = attachment; this.key = key; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + AttachmentModel that = (AttachmentModel)o; + + return attachment.equals(that.attachment); + + } + + @Override + public int hashCode() { + return attachment.hashCode(); + } } } diff --git a/src/org/thoughtcrime/securesms/mms/DecryptableStreamUriLoader.java b/src/org/thoughtcrime/securesms/mms/DecryptableStreamUriLoader.java index bfb3a0a09e5..b5fcdf3143f 100644 --- a/src/org/thoughtcrime/securesms/mms/DecryptableStreamUriLoader.java +++ b/src/org/thoughtcrime/securesms/mms/DecryptableStreamUriLoader.java @@ -2,6 +2,7 @@ import android.content.Context; import android.net.Uri; +import android.support.annotation.NonNull; import com.bumptech.glide.load.data.DataFetcher; import com.bumptech.glide.load.model.GenericLoaderFactory; @@ -48,13 +49,29 @@ public DataFetcher getResourceFetcher(DecryptableUri model, int wid } public static class DecryptableUri { - public MasterSecret masterSecret; - public Uri uri; + public @NonNull MasterSecret masterSecret; + public @NonNull Uri uri; - public DecryptableUri(MasterSecret masterSecret, Uri uri) { + public DecryptableUri(@NonNull MasterSecret masterSecret, @NonNull Uri uri) { this.masterSecret = masterSecret; this.uri = uri; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + DecryptableUri that = (DecryptableUri)o; + + return uri.equals(that.uri); + + } + + @Override + public int hashCode() { + return uri.hashCode(); + } } }