ImageViewLoadConfiguration

class ImageViewLoadConfiguration(var source: Any? = null, var transformation: ImageViewLoadConfiguration.ImageTransformation? = null, var progressBar: ProgressBar? = null, var onImageLoaded: () -> Unit? = null, var onImageNotLoaded: () -> Unit? = null)

ImageViewLoadConfiguration define setup and configuration to load an image into ImageView using Glide

Author

jimlyas

Since

13 Jan 2023

Parameters

source

the image source that will be loaded into ImageView, supported type is Int, String, and Drawable

transformation

ImageTransformation to define how the size of the image will be displayed by the ratio of ImageView

progressBar

ProgressBar that will be listen when the image is loaded, will be displayed when the image still currently loading and will be hidden when the image already loaded, null by default

onImageLoaded

listener for when the image is successfully loaded, null by default

onImageNotLoaded

listener for when the image is failed to load, null by default

Constructors

Link copied to clipboard
constructor(source: Any? = null, transformation: ImageViewLoadConfiguration.ImageTransformation? = null, progressBar: ProgressBar? = null, onImageLoaded: () -> Unit? = null, onImageNotLoaded: () -> Unit? = null)

Types

Link copied to clipboard

enum class that define image transformation for Glide

Functions

Link copied to clipboard
fun withErrorImage(errorImage: Any?)

Function to register error image when failed to load the source image

Link copied to clipboard
fun withImageLoaded(action: () -> Unit)

Function to register listener when the source image is successfully loaded

Link copied to clipboard
fun withImageNotLoaded(action: () -> Unit)

Function to register listener when the source image is failed to load

Link copied to clipboard
fun withImageSource(source: Any?)

Function to set the image source to load to ImageView

Link copied to clipboard
fun withPlaceHolder(placeHolder: Any?)

Function to register placeHolder image while the image is still loading

Link copied to clipboard
fun withProgressBar(progressBar: ProgressBar)

Function to register ProgressBar to listen to loading source image

Link copied to clipboard

Function to set transformation to the image being loaded, e.g ImageTransformation.FitCenter or ImageTransformation.Circle

Properties

Link copied to clipboard
val loadListener: RequestListener<Drawable>

RequestListener to listen the state of image loading, used for displaying and hiding ProgressBar and running onImageLoaded or onImageNotLoaded

Link copied to clipboard
var onImageLoaded: () -> Unit?
Link copied to clipboard
Link copied to clipboard
val options: RequestOptions

RequestOptions for holding Glide configuration

Link copied to clipboard
Link copied to clipboard
var source: Any?