Coil: Is there a way to use a request as placeholder?

Created on 3 Dec 2019  路  1Comment  路  Source: coil-kt/coil

Say I have a placeholder image url and the actual image url. Is it possible for me to load the placeholder first, and then upon completion load the actual image?

I already tried this without success

Coil.load(context, thumbnail) {
            crossfade(true)
            target {
                setImageDrawable(it)
                load(url) { crossfade(true) }
            }
        }
question

Most helpful comment

Placeholders can only be set synchronously at the moment, however you could work around this by chaining two load operations:

Coil.load(context, thumbnail) {
    crossfade(true)
    target { thumbnailDrawable ->
        imageView.load(fullSize) {
            crossfade(true)
            placeholder(thumbnailDrawable)
        }
    }
}

I'm tracking support for asynchronous placeholders here: #27

>All comments

Placeholders can only be set synchronously at the moment, however you could work around this by chaining two load operations:

Coil.load(context, thumbnail) {
    crossfade(true)
    target { thumbnailDrawable ->
        imageView.load(fullSize) {
            crossfade(true)
            placeholder(thumbnailDrawable)
        }
    }
}

I'm tracking support for asynchronous placeholders here: #27

Was this page helpful?
0 / 5 - 0 ratings