我现在面临的问题与滑翔为什么使用View.getContext()不太流行?
You cannot start a load for a destroyed activity
我没有看到这个崩溃我只是报道说发生这种情况,那么我检查了我的代码,我看到了我写的:
public static void setImageWithGlide(Context context, String imageUrl, ImageView imageView) {
if (context != null && imageView != null)
Glide.with(context).load(imageUrl)
.dontAnimate().into(imageView);
}
所以,我做了一些阅读,看到人们在使用
1 - Context
,像我一样
2 - `应用上下文”,这不是好主意人l对于很多原因
3 - 获取上下文从View
本身所以在我的情况下,它会变成:
public static void setImageWithGlide(String imageUrl, ImageView imageView) {
if (imageView != null && imageView.getContext() != null)
Glide.with(imageView.getContext()).load(imageUrl)
.dontAnimate().into(imageView);
}
我不知道这是否会解决这个问题,但为什么越来越上下文的这种方式是不流行?不使用它的原因是什么?这也节省了我传递给方法(对我个人并不好,因为我也想知道,使用方面,我知道当我传递这个方法)
这样的背景下...
1。 Context
是正确还是错误的情况? 2。你认为有更好的方法来解决这个问题吗?
顺便说一下,我不认为用户看到这个崩溃,它可能会在Glide内部处理。
如果你正面临这个问题的链接,由于活动的getContext然后从任何杀戮也不会工作 –
你会建议? –