coil-kt / coil

Image loading for Android and Compose Multiplatform.

Home Page:https://coil-kt.github.io/coil/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automatically retry image requests after regaining network connectivity

ismailnurudeen opened this issue · 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?.

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.

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?

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

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

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.

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 .

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

@colinrtwhite, hi. Any updates on this issue?