load Image

fun ImageView.loadImage(    imageDrawable: Drawable? = null,     imageUrl: String? = null,     imageRes: Int? = null,     placeHolderDrawable: Drawable? = null,     placeHolderResourceId: Int? = null,     progressBar: ProgressBar? = null,     errorResourceId: Int? = null,     errorDrawable: Drawable? = null,     onImageLoaded: () -> Unit? = null,     onImageNotLoaded: () -> Unit? = null,     scaleType: ImageView.ScaleType = CENTER_CROP)

Method to load image to ImageView, please read carefully what param you can use

There's 3 valid object you can load to ImageView here, you must use one of these three

Parameters

imageDrawable

drawable of the image to load

imageUrl

url of the image to load

imageRes

resource id of the image to load

You can add placeHolder when loading Image, choose one of these two

placeHolderDrawable

drawable of the placeHolder

placeHolderResourceId

resource id of the placeholder

You can add progressBar when loading the image, for that pass value for this parameter

progressBar

progressbar to display when image is loading

You can add error image when the process failed, choose one of these two

errorDrawable

drawable of the error image

errorResourceId

resource id of error image

onImageLoaded

action when the image is loaded, null by default

onImageNotLoaded

action when the image fail to load, null by default

You can set the ScaleType of the image, if not defined the default value is CENTER_CROP

scaleType

scaleType of image that will be loaded


fun ImageView.loadImage(configuration: loadConfiguration)

Sources

Link copied to clipboard
Link copied to clipboard