coil icon indicating copy to clipboard operation
coil copied to clipboard

Automatically retry image requests after regaining network connectivity

Open ismailnurudeen opened this issue 5 years ago • 9 comments

I am using the code below to load images from a URL into the target imageview When i try to load the images without internet connection,the error image is displayed,then if i turn on internet connection,unlike Glide, Coil doesn't try to reload the images from the URL.

 fun loadImageWithCoil(
        target: ImageView,
        imgUrl: String?,
        placeHolder: Int = R.drawable.profile_pic_placeholder,
        errorImg:Int=R.drawable.ic_terrain_black_24dp
    ) {
        target.load(imgUrl) {
            placeholder(placeHolder)
            crossfade(true)
            error(errorImg)
        }

    }

Is this currently not possible or I'm not doing it right?.

ismailnurudeen avatar Sep 30 '19 12:09 ismailnurudeen

Yep, this is currently not implemented. Coil will automatically force reading from the disk cache if you're offline, but it won't restart a request when you come back online.

colinrtwhite avatar Sep 30 '19 17:09 colinrtwhite

Is there a reason associated with Coil's nature or performance why this is currently not implemented or it's something we should be expecting soon?

ismailnurudeen avatar Oct 01 '19 06:10 ismailnurudeen

@ElNuru247 I think this could be implemented, though it's low priority. I've shied away from adding it so far as I'm not sure how much complexity it would add to Coil.

colinrtwhite avatar Oct 01 '19 17:10 colinrtwhite

I would assume "lots". Network connectivity is different from being able to load something from network for various reasons.

mario avatar Oct 14 '19 20:10 mario

Any progress on this point? or anybody here has some workaround for this use case?

I am using Coil to show an image library (from the internet) on a RecyclerView, and I would like to refresh the images not loaded when the device regaining network connectivity.

magnumrocha avatar Jul 08 '20 17:07 magnumrocha

Is there possible to retry the failed net-work request delay after 1s or 3s or notify the failed request when net-work switch WIFI from 4G or switch 4G from WIFI if the view or the lifecycle is still alive ? I do think that the way to automatically retry image requests after regaining network connectivity is not easy to solve it , because the net-work has complicated situation .

ShowMeThe avatar Oct 23 '20 06:10 ShowMeThe

Fresco has tap to reload (after a failure). Maybe coil can do the same ?

ouattararomuald avatar Jun 29 '21 15:06 ouattararomuald

@colinrtwhite, hi. Any updates on this issue?

Obolrom avatar Mar 04 '23 23:03 Obolrom