add equals/hashCode to glide models

Closes #4737
// FREEBIE
This commit is contained in:
Jake McGinty
2015-11-27 14:45:07 -08:00
committed by Moxie Marlinspike
parent e83827ab75
commit 946c43940b
4 changed files with 44 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.mms;
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 class AttachmentStreamUriLoader implements StreamModelLoader<AttachmentMo
}
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();
}
}
}

View File

@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.mms;
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 class DecryptableStreamUriLoader implements StreamModelLoader<Decryptable
}
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();
}
}
}