简体   繁体   中英

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. 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.

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.

problem is NetworkImageView taking drawable resource id only as a default placeholder or error image, it should take dynamic url too

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()
                        {

                        }
                    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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