mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Fix possible data race in ThumbnailView after image send.
This commit is contained in:
@@ -47,6 +47,7 @@ import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
|
||||
import org.thoughtcrime.securesms.util.concurrent.SettableFuture;
|
||||
import org.thoughtcrime.securesms.util.views.Stub;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
@@ -378,7 +379,7 @@ public class ThumbnailView extends FrameLayout {
|
||||
this.playOverlay.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (Util.equals(slide, this.slide)) {
|
||||
if (hasSameContents(this.slide, slide)) {
|
||||
Log.i(TAG, "Not re-loading slide " + slide.asAttachment().getUri());
|
||||
return new SettableFuture<>(false);
|
||||
}
|
||||
@@ -609,6 +610,20 @@ public class ThumbnailView extends FrameLayout {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static boolean hasSameContents(@Nullable Slide slide, @Nullable Slide other) {
|
||||
if (Util.equals(slide, other)) {
|
||||
|
||||
if (slide != null && other != null) {
|
||||
byte[] digestLeft = slide.asAttachment().getDigest();
|
||||
byte[] digestRight = other.asAttachment().getDigest();
|
||||
|
||||
return Arrays.equals(digestLeft, digestRight);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public interface ThumbnailRequestListener extends RequestListener<Drawable> {
|
||||
void onLoadCanceled();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user