Translations: 简体中文
ImageOptions is used to define image request configurations in batches and supports all image-related attributes of ImageRequest.
ImageOptions can currently be used in three places:
- View
- SketchImageView.displayImageOptions
- SketchZoomImageView.displayImageOptions
- ImageRequest.Builder.merge()/default()
- Sketch.globalImageOptions
Ultimately when building ImageRequest it will end up as ImageRequest.Builder > View > ImageRequest Sequential build of .Builder.defaultOptions > Sketch.globalImageOptions
Global:
class MyApplication : Application(), SketchFactory {
override fun createSketch(): Sketch {
return Sketch.Builder(this).apply {
globalImageOptions(ImageOptions {
placeholer(R.drawable.placeholder)
error(R.drawable.error)
// more ...
})
}.build()
}
}
View:
sketchImageView.displayImageOptions = ImageOptions {
placeholer(R.drawable.placeholder)
// more ...
}
// Update based on existing ImageOptions
sketchImageView.updateDisplayImageOptions {
error(R.drawable.error)
}
ImageRequest:
DisplayRequest(context, "http://sample.com/sample.jpeg") {
merge(ImageOptions {
// ...
})
default(ImageOptions {
// ...
})
}