Class ImageSource

  • All Implemented Interfaces:

    
    public final class ImageSource
    
                        

    Helper class used to set the source and additional attributes from a variety of sources. Supports use of a bitmap, asset, resource, external file or any other URI.

    When you are using a preview image, you must set the dimensions of the full size image on the ImageSource object for the full size image using the dimensions method.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • resource

         static ImageSource resource(int resId)

        Create an instance from a resource. The correct resource for the device screen resolution will be used.

        Parameters:
        resId - resource ID.
      • asset

         static ImageSource asset(String assetName)

        Create an instance from an asset name.

        Parameters:
        assetName - asset name.
      • uri

         static ImageSource uri(String uri)

        Create an instance from a URI. If the URI does not start with a scheme, it's assumed to be the URI of a file.

        Parameters:
        uri - image URI.
      • uri

         static ImageSource uri(Uri uri)

        Create an instance from a URI.

        Parameters:
        uri - image URI.
      • bitmap

         static ImageSource bitmap(Bitmap bitmap)

        Provide a loaded bitmap for display.

        Parameters:
        bitmap - bitmap to be displayed.
      • cachedBitmap

         static ImageSource cachedBitmap(Bitmap bitmap)

        Provide a loaded and cached bitmap for display. This bitmap will not be recycled when it is no longer needed. Use this method if you loaded the bitmap with an image loader such as Picasso or Volley.

        Parameters:
        bitmap - bitmap to be displayed.
      • tilingEnabled

         ImageSource tilingEnabled()

        Enable tiling of the image. This does not apply to preview images which are always loaded as a single bitmap., and tiling cannot be disabled when displaying a region of the source image.

        Returns:

        this instance for chaining.

      • tilingDisabled

         ImageSource tilingDisabled()

        Disable tiling of the image. This does not apply to preview images which are always loaded as a single bitmap, and tiling cannot be disabled when displaying a region of the source image.

        Returns:

        this instance for chaining.

      • tiling

         ImageSource tiling(boolean tile)

        Enable or disable tiling of the image. This does not apply to preview images which are always loaded as a single bitmap, and tiling cannot be disabled when displaying a region of the source image.

        Returns:

        this instance for chaining.

      • region

         ImageSource region(Rect sRegion)

        Use a region of the source image. Region must be set independently for the full size image and the preview if you are using one.

        Returns:

        this instance for chaining.

      • dimensions

         ImageSource dimensions(int sWidth, int sHeight)

        Declare the dimensions of the image. This is only required for a full size image, when you are specifying a URI and also a preview image. When displaying a bitmap object, or not using a preview, you do not need to declare the image dimensions. Note if the declared dimensions are found to be incorrect, the view will reset.

        Returns:

        this instance for chaining.