简体   繁体   English

如何首先从NetworkImageView中的URL显示缩略图图像并在后台请求大尺寸图像并在下载大图像时显示?

[英]How to first show thumb image from URL in NetworkImageView and request a large size image in background and show when large one downloaded?

I am using Volley and I have a single NetworkImageView with two image urls, one small thumb image and other large full size image. 我正在使用Volley,并且我有一个NetworkImageView,其中包含两个图像URL,一个小拇指图像和其他大尺寸全尺寸图像。 I want to first check in cache for large image, if it found then show in NetworkImageView else check thumb image in cache if found then show in view and if not found then first load thumb image from a url in NetworkImageView. 我想先检查缓存中是否有大图像,如果找到,然后在NetworkImageView中显示;否则,检查缓存中的缩略图(如果找到),然后在视图中显示;如果未找到,则首先从NetworkImageView中的URL加载缩略图。

at the same time if large image not found in cache then request large image url in background and replace thumb image with large image when download completed. 同时,如果在缓存中找不到大图像,则在后台请求大图像url,并在下载完成后将拇指图像替换为大图像。

problem is NetworkImageView taking drawable resource id only as a default placeholder or error image, it should take dynamic url too 问题是NetworkImageView仅将可绘制资源ID用作默认占位符或错误图像,它也应该采用动态网址

i have solved my issue using below code: 我已经使用以下代码解决了我的问题:

Picasso.with(getActivity())
                    .load(thumbImageUrl)
                    .error(defaultImageUrl)
                    .placeholder(defaultImageUrl)
                    .into(ImageView_sliderImage, new Callback()
                    {
                        @Override
                        public void onSuccess()
                        {
                            if(imageUrl!=null && imageUrl.length()>0)
                            {
                                Picasso.with(getActivity())
                                        .load(biggerImageUrl)
                                        .error(defaultImageUrl)
                                        .placeholder(ImageView_sliderImage.getDrawable())
                                        .into(ImageView_sliderImage);
                            }
                        }
                        @Override
                        public void onError()
                        {

                        }
                    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM