Fix crash in GlideImageGetter.

This commit is contained in:
Alex Ning 2020-11-19 19:25:25 +08:00
parent c21d59e979
commit 4904d46cb2

View File

@ -58,13 +58,18 @@ public class GlideImageGetter implements Html.ImageGetter {
BitmapDrawablePlaceholder drawable = new BitmapDrawablePlaceholder(textSize); BitmapDrawablePlaceholder drawable = new BitmapDrawablePlaceholder(textSize);
Context context = container.get().getContext(); container.get().post(() -> {
if (!(context instanceof Activity && (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()))) { TextView textView = container.get();
container.get().post(() -> Glide.with(context) if (textView != null) {
.asBitmap() Context context = textView.getContext();
.load(source) if (!(context instanceof Activity && (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()))) {
.into(drawable)); Glide.with(context)
} .asBitmap()
.load(source)
.into(drawable);
}
}
});
return drawable; return drawable;
} }