Skip to content

Instantly share code, notes, and snippets.

@vincent-paing
Created August 21, 2019 11:04
Show Gist options
  • Save vincent-paing/5c684aa46f5e41886e3c7af603418ec3 to your computer and use it in GitHub Desktop.
Save vincent-paing/5c684aa46f5e41886e3c7af603418ec3 to your computer and use it in GitHub Desktop.
inline fun ImageView.loadWithDefault(
url: String?,
imageLoader: ImageLoader = Coil.loader(),
builder: LoadRequestBuilder.() -> Unit = {}
): RequestDisposable {
val loadRequestBuilder = LoadRequestBuilder(
this.context, LoadRequest(
this.context,
defaults = DefaultRequestOptions()
)
)
.data(url)
.target(this@loadWithDefault)
.apply(builder)
return imageLoader.load(loadRequestBuilder.build())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment