Skip to content

Latest commit

 

History

History
73 lines (54 loc) · 1.89 KB

image_options.md

File metadata and controls

73 lines (54 loc) · 1.89 KB

ImageOptions

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:

Ultimately when building ImageRequest it will end up as ImageRequest.Builder > View > ImageRequest Sequential build of .Builder.defaultOptions > Sketch.globalImageOptions

Example

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 {
        // ...
    })
}