Don't use Glide when the Activity is marked as destroyed

This commit is contained in:
cketti 2021-08-03 22:09:17 +02:00
parent d22bb731f6
commit 2328abd3a1

View file

@ -1,6 +1,7 @@
package com.fsck.k9.ui.messageview;
import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
@ -120,8 +121,14 @@ public class AttachmentView extends FrameLayout implements OnClickListener {
}
public void refreshThumbnail() {
Context context = getContext();
if (context instanceof Activity && ((Activity) context).isDestroyed()) {
// Do nothing because Glide would throw an exception
return;
}
preview.setVisibility(View.VISIBLE);
Glide.with(getContext())
Glide.with(context)
.load(attachment.internalUri)
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.NONE)