From a95da2c219d714fe76885620b972f0d618ac7e39 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Tue, 21 Jul 2020 11:51:01 +1000 Subject: [PATCH] Fix Giphy crash --- .../securesms/giph/model/ChunkedImageUrl.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/giph/model/ChunkedImageUrl.java b/src/org/thoughtcrime/securesms/giph/model/ChunkedImageUrl.java index d425c0ceac..bf5ee63659 100644 --- a/src/org/thoughtcrime/securesms/giph/model/ChunkedImageUrl.java +++ b/src/org/thoughtcrime/securesms/giph/model/ChunkedImageUrl.java @@ -14,7 +14,7 @@ public class ChunkedImageUrl implements Key { public static final long SIZE_UNKNOWN = -1; private final String url; - private final long size; + private final long size; public ChunkedImageUrl(@NonNull String url) { this(url, SIZE_UNKNOWN); @@ -22,7 +22,7 @@ public class ChunkedImageUrl implements Key { public ChunkedImageUrl(@NonNull String url, long size) { this.url = url; - this.size = size; + this.size = size; } public String getUrl() { @@ -35,6 +35,7 @@ public class ChunkedImageUrl implements Key { @Override public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { + if (url == null) { return; } messageDigest.update(url.getBytes()); messageDigest.update(Conversions.longToByteArray(size)); } @@ -45,12 +46,14 @@ public class ChunkedImageUrl implements Key { ChunkedImageUrl that = (ChunkedImageUrl)other; + if (this.url == null || that.url == null) { return false; } + return this.url.equals(that.url) && this.size == that.size; } @Override public int hashCode() { + if (url == null) { return 0; } return url.hashCode() ^ (int)size; } - }