【一】Glide错误IllegalArgumentException: You cannot start a load for a destroyed activity

Reason: If you load 100 pictures in the adapter of a page, and you haven’t finished loading finish, next time you enter this page, the picture will be loaded according to the last acitvity address cached, but the last address has been killed (finish ), the words are rather messy, and I don’t know how to express them. understand understand.

The solution is to judge whether the context is empty when loading pictures with Glide

@Override
     if(context !=null){
            mGlideRequest = Glide.with(context).load(url).placeholder(R.drawable.default_img).dontAnimate().error(R.drawable.default_img);
        }else
            return null;

problem solved.

I see that there is a solution recommended by the author in the issue on github, which is to judge whether the context is empty every time the image is loaded
, and current activity is destroyed.

Original issue address: https://github.com/bumptech/glide/issues/803
Solution address: https://stackoverflow.com/questions/31964737/glide-image-loading-with-application-context/32887693#32887693

This problem has not occurred in the use of Glide4.0 after testing. Updated 18.4.2

Guess you like

Origin blog.csdn.net/a940659387/article/details/50555327