Save image once Glide has loaded it

大憨熊 提交于 2019-12-03 09:14:56
Nilesh Singh

Use the listener so that when the image is fetched and ready to be used, you can save it using the saveImage method of yours.

Do this:

Glide.with(getContext()).load(apdInfo.url)
     .thumbnail(0.5f)
     .crossFade()
     .diskCacheStrategy(DiskCacheStrategy.ALL)
     .into(new SimpleTarget<GlideDrawable>() {
                @Override
                public void onResourceReady(GlideDrawable glideDrawable, GlideAnimation<? super GlideDrawable> glideAnimation) {
                    apd_image.setImageDrawable(glideDrawable);
                    apd_image.setDrawingCacheEnabled(true);
                    saveImage();
      }});

Call the saveImage method inside onResourceReady() callback and use the GlideDrawable resource. I would suggest using the GlideDrawable rather than getting the image using Drawing Cache.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!