-
- All Implemented Interfaces:
public final class CoilImage
-
-
Method Summary
Modifier and Type Method Description final static UnitCoilImage(Object imageModel, Modifier modifier, Context context, LifecycleOwner lifecycleOwner, Function0<ImageLoader> imageLoader, ImageComponent component, ImageRequest.Listener requestListener, ImageOptions imageOptions, Function1<CoilImageState, Unit> onImageStateChanged, @DrawableRes() Integer previewPlaceholder, Function2<BoxScope, CoilImageState.Loading, Unit> loading, Function2<BoxScope, CoilImageState.Success, Unit> success, Function2<BoxScope, CoilImageState.Failure, Unit> failure)Load and render an image with the given imageModel from the network or local storage. final static UnitCoilImage(ImageRequest imageRequest, Modifier modifier, Function0<ImageLoader> imageLoader, ImageComponent component, ImageOptions imageOptions, Function1<CoilImageState, Unit> onImageStateChanged, @DrawableRes() Integer previewPlaceholder, Function2<BoxScope, CoilImageState.Loading, Unit> loading, Function2<BoxScope, CoilImageState.Success, Unit> success, Function2<BoxScope, CoilImageState.Failure, Unit> failure)Load and render an image with the given imageRequest from the network or local storage. -
-
Method Detail
-
CoilImage
final static Unit CoilImage(Object imageModel, Modifier modifier, Context context, LifecycleOwner lifecycleOwner, Function0<ImageLoader> imageLoader, ImageComponent component, ImageRequest.Listener requestListener, ImageOptions imageOptions, Function1<CoilImageState, Unit> onImageStateChanged, @DrawableRes() Integer previewPlaceholder, Function2<BoxScope, CoilImageState.Loading, Unit> loading, Function2<BoxScope, CoilImageState.Success, Unit> success, Function2<BoxScope, CoilImageState.Failure, Unit> failure)
Load and render an image with the given imageModel from the network or local storage.
Supported types for the imageModel are the below: String, Uri, HttpUrl, File, DrawableRes, Drawable, Bitmap, ByteArray, ByteBuffer
CoilImage( imageModel = imageModel, modifier = modifier, imageOptions = ImageOptions(contentScale = ContentScale.Crop), loading = { Box(modifier = Modifier.matchParentSize()) { CircularProgressIndicator( modifier = Modifier.align(Alignment.Center) ) } }, failure = { Text(text = "image request failed.") })- Parameters:
imageModel- The data model to request image.modifier- Modifier used to adjust the layout or drawing content.context- The context for creating the ImageRequest.Builder.lifecycleOwner- The LifecycleOwner for constructing the ImageRequest.Builder.imageLoader- The ImageLoader to use when requesting the image.component- An image component that conjuncts pluggable ImagePlugins.requestListener- A class for monitoring the status of a request while images load.imageOptions- Represents parameters to load generic Image Composable.onImageStateChanged- An image state change listener will be triggered whenever the image state is changed.previewPlaceholder- Drawable resource ID which will be displayed when this function is ran in preview mode.loading- Content to be displayed when the request is in progress.success- Content to be displayed when the request is succeeded.failure- Content to be displayed when the request is failed.
-
CoilImage
final static Unit CoilImage(ImageRequest imageRequest, Modifier modifier, Function0<ImageLoader> imageLoader, ImageComponent component, ImageOptions imageOptions, Function1<CoilImageState, Unit> onImageStateChanged, @DrawableRes() Integer previewPlaceholder, Function2<BoxScope, CoilImageState.Loading, Unit> loading, Function2<BoxScope, CoilImageState.Success, Unit> success, Function2<BoxScope, CoilImageState.Failure, Unit> failure)
Load and render an image with the given imageRequest from the network or local storage.
CoilImage( imageRequest = ImageRequest.Builder(context) .data(imageModel) .lifecycle(lifecycleOwner) .build(), modifier = modifier, loading = { Box(modifier = Modifier.matchParentSize()) { CircularProgressIndicator( modifier = Modifier.align(Alignment.Center) ) } }, failure = { Text(text = "image request failed.") })- Parameters:
imageRequest- The request to execute.modifier- Modifier used to adjust the layout or drawing content.imageLoader- The ImageLoader to use when requesting the image.component- An image component that conjuncts pluggable ImagePlugins.imageOptions- Represents parameters to load generic Image Composable.onImageStateChanged- An image state change listener will be triggered whenever the image state is changed.previewPlaceholder- Drawable resource ID which will be displayed when this function is ran in preview mode.loading- Content to be displayed when the request is in progress.success- Content to be displayed when the request is succeeded.failure- Content to be displayed when the request is failed.
-
-
-
-