Package 

Class CoilImage

  • All Implemented Interfaces:

    
    public final class CoilImage
    
                        
    • Constructor Detail

    • Method Detail

      • CoilImage

         final static Unit CoilImage(Object imageModel, Modifier modifier, Context context, LifecycleOwner lifecycleOwner, Function0<ImageLoader> imageLoader, ImageRequest.Listener requestListener, Alignment alignment, Float alpha, ContentScale contentScale, String contentDescription, CircularReveal circularReveal, ColorFilter colorFilter, ShimmerParams shimmerParams, BitmapPalette bitmapPalette, Object error, @DrawableRes() Integer previewPlaceholder)

        Requests loading an image with a loading placeholder and error image resource (ImageBitmap, ImageVector, Painter).

        CoilImage(
          imageModel = imageModel,
        shimmerParams = ShimmerParams (
         baseColor = backgroundColor,
         highlightColor = highlightColor
        ),
         error = ImageBitmap.imageResource(R.drawable.error)
        )

        or we can use ImageVector or custom Painter like the below.

        error = ImageVector.vectorResource(R.drawable.error)
        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.
        requestListener - A class for monitoring the status of a request while images load.
        alignment - The alignment parameter used to place the loaded ImageBitmap in the image container.
        alpha - The alpha parameter used to apply for the image when it is rendered onscreen.
        contentScale - The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
        contentDescription - The content description used to provide accessibility to describe the image.
        circularReveal - circular reveal parameters for running reveal animation when images are successfully loaded.
        colorFilter - The colorFilter parameter used to apply for the image when it is rendered onscreen.
        shimmerParams - The shimmer related parameter used to determine constructions of the Shimmer.
        bitmapPalette - A Palette generator for extracting major (theme) colors from images.
        error - An ImageBitmap, ImageVector, or Painter for showing instead of the target image when images are failed to load.
        previewPlaceholder - Drawable resource ID which will be displayed when this function is ran in preview mode.
      • CoilImage

         final static Unit CoilImage(Object imageModel, Modifier modifier, Context context, LifecycleOwner lifecycleOwner, Function0<ImageLoader> imageLoader, ImageRequest.Listener requestListener, Alignment alignment, Float alpha, ContentScale contentScale, String contentDescription, CircularReveal circularReveal, BitmapPalette bitmapPalette, ColorFilter colorFilter, Object placeHolder, Object error, @DrawableRes() Integer previewPlaceholder)

        Requests loading an image with a loading placeholder and error image resource (ImageBitmap, ImageVector, Painter).

        CoilImage(
          imageModel = imageModel,
          placeHolder = ImageBitmap.imageResource(R.drawable.placeholder),
          error = ImageBitmap.imageResource(R.drawable.error)
        )

        or we can use ImageVector or custom Painter like the below.

        placeHolder = ImageVector.vectorResource(R.drawable.placeholder)
        error = ImageVector.vectorResource(R.drawable.error)
        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.
        requestListener - A class for monitoring the status of a request while images load.
        alignment - The alignment parameter used to place the loaded ImageBitmap in the image container.
        alpha - The alpha parameter used to apply for the image when it is rendered onscreen.
        contentScale - The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
        contentDescription - The content description used to provide accessibility to describe the image.
        circularReveal - circular reveal parameters for running reveal animation when images are successfully loaded.
        bitmapPalette - A Palette generator for extracting major (theme) colors from images.
        colorFilter - The colorFilter parameter used to apply for the image when it is rendered onscreen.
        placeHolder - An ImageBitmap, ImageVector, or Painter to be displayed when the request is in progress.
        error - An ImageBitmap, ImageVector, or Painter for showing instead of the target image when images are failed to load.
        previewPlaceholder - Drawable resource ID which will be displayed when this function is ran in preview mode.
      • CoilImage

         final static Unit CoilImage(Object imageModel, Modifier modifier, Context context, LifecycleOwner lifecycleOwner, Function0<ImageLoader> imageLoader, ImageRequest.Listener requestListener, Alignment alignment, ContentScale contentScale, String contentDescription, Float alpha, ColorFilter colorFilter, CircularReveal circularReveal, ShimmerParams shimmerParams, BitmapPalette bitmapPalette, @DrawableRes() Integer previewPlaceholder, Function2<BoxScope, CoilImageState.Success, Unit> success, Function2<BoxScope, CoilImageState.Failure, Unit> failure)

        Requests loading an image and create some composables based on CoilImageState.

        CoilImage(
        imageModel = imageModel,
        modifier = modifier,
        shimmerParams = ShimmerParams (
         baseColor = backgroundColor,
         highlightColor = highlightColor
        ),
        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.
        requestListener - A class for monitoring the status of a request while images load.
        alignment - The alignment parameter used to place the loaded ImageBitmap in the image container.
        contentScale - The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
        contentDescription - The content description used to provide accessibility to describe the image.
        alpha - The alpha parameter used to apply for the image when it is rendered onscreen.
        colorFilter - The colorFilter parameter used to apply for the image when it is rendered onscreen.
        circularReveal - circular reveal parameters for running reveal animation when images are successfully loaded.
        bitmapPalette - A Palette generator for extracting major (theme) colors from images.
        previewPlaceholder - Drawable resource ID which will be displayed when this function is ran in preview mode.
        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(Object imageModel, Modifier modifier, Context context, LifecycleOwner lifecycleOwner, Function0<ImageLoader> imageLoader, ImageRequest.Listener requestListener, Alignment alignment, ContentScale contentScale, String contentDescription, Float alpha, ColorFilter colorFilter, CircularReveal circularReveal, BitmapPalette bitmapPalette, @DrawableRes() Integer previewPlaceholder, Function2<BoxScope, CoilImageState.Loading, Unit> loading, Function2<BoxScope, CoilImageState.Success, Unit> success, Function2<BoxScope, CoilImageState.Failure, Unit> failure)

        Requests loading an image and create some composables based on CoilImageState.

        CoilImage(
        imageModel = imageModel,
        modifier = modifier,
        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.
        requestListener - A class for monitoring the status of a request while images load.
        alignment - The alignment parameter used to place the loaded ImageBitmap in the image container.
        contentScale - The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
        contentDescription - The content description used to provide accessibility to describe the image.
        alpha - The alpha parameter used to apply for the image when it is rendered onscreen.
        colorFilter - The colorFilter parameter used to apply for the image when it is rendered onscreen.
        circularReveal - circular reveal parameters for running reveal animation when images are successfully loaded.
        bitmapPalette - A Palette generator for extracting major (theme) colors from images.
        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, Alignment alignment, ContentScale contentScale, String contentDescription, Float alpha, ColorFilter colorFilter, CircularReveal circularReveal, ShimmerParams shimmerParams, BitmapPalette bitmapPalette, @DrawableRes() Integer previewPlaceholder, Function2<BoxScope, CoilImageState.Success, Unit> success, Function2<BoxScope, CoilImageState.Failure, Unit> failure)

        Requests loading an image and create some composables based on CoilImageState.

        CoilImage(
        imageRequest = ImageRequest.Builder(context)
             .data(imageModel)
             .lifecycle(lifecycleOwner)
             .build(),
        modifier = modifier,
        shimmerParams = ShimmerParams (
         baseColor = backgroundColor,
         highlightColor = highlightColor
        ),
        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.
        alignment - The alignment parameter used to place the loaded ImageBitmap in the image container.
        contentScale - The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
        contentDescription - The content description used to provide accessibility to describe the image.
        alpha - The alpha parameter used to apply for the image when it is rendered onscreen.
        colorFilter - The colorFilter parameter used to apply for the image when it is rendered onscreen.
        circularReveal - circular reveal parameters for running reveal animation when images are successfully loaded.
        bitmapPalette - A Palette generator for extracting major (theme) colors from images.
        previewPlaceholder - Drawable resource ID which will be displayed when this function is ran in preview mode.
        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, Alignment alignment, ContentScale contentScale, String contentDescription, Float alpha, ColorFilter colorFilter, CircularReveal circularReveal, BitmapPalette bitmapPalette, @DrawableRes() Integer previewPlaceholder, Function2<BoxScope, CoilImageState.Loading, Unit> loading, Function2<BoxScope, CoilImageState.Success, Unit> success, Function2<BoxScope, CoilImageState.Failure, Unit> failure)

        Requests loading an image and create some composables based on CoilImageState.

        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.
        alignment - The alignment parameter used to place the loaded ImageBitmap in the image container.
        contentScale - The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.
        contentDescription - The content description used to provide accessibility to describe the image.
        alpha - The alpha parameter used to apply for the image when it is rendered onscreen.
        colorFilter - The colorFilter parameter used to apply for the image when it is rendered onscreen.
        circularReveal - circular reveal parameters for running reveal animation when images are successfully loaded.
        bitmapPalette - A Palette generator for extracting major (theme) colors from images.
        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.