/** * Create an instance from a resource. The correct resource for the device screen resolution will be used. * @param resId resource ID. * @return an {@link ImageSource} instance. */ @NonNull public static ImageSource resource(int resId) { return new ImageSource(resId); }
/** * Create an instance from a URI. * @param uri image URI. * @return an {@link ImageSource} instance. */ @NonNull public static ImageSource uri(@NonNull Uri uri) { //noinspection ConstantConditions if (uri == null) { throw new NullPointerException("Uri must not be null"); } return new ImageSource(uri); }
/** * Provide a loaded bitmap for display. * @param bitmap bitmap to be displayed. * @return an {@link ImageSource} instance. */ @NonNull public static ImageSource bitmap(@NonNull Bitmap bitmap) { //noinspection ConstantConditions if (bitmap == null) { throw new NullPointerException("Bitmap must not be null"); } return new ImageSource(bitmap, false); }
/** * 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. * @param bitmap bitmap to be displayed. * @return an {@link ImageSource} instance. */ @NonNull public static ImageSource cachedBitmap(@NonNull Bitmap bitmap) { //noinspection ConstantConditions if (bitmap == null) { throw new NullPointerException("Bitmap must not be null"); } return new ImageSource(bitmap, true); }
/** * 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. * @param uri image URI. * @return an {@link ImageSource} instance. */ @NonNull public static ImageSource uri(@NonNull String uri) { //noinspection ConstantConditions if (uri == null) { throw new NullPointerException("Uri must not be null"); } if (!uri.contains("://")) { if (uri.startsWith("/")) { uri = uri.substring(1); } uri = FILE_SCHEME + uri; } return new ImageSource(Uri.parse(uri)); }
/** * Create an instance from a resource. The correct resource for the device screen resolution will be used. * @param resId resource ID. */ public static ImageSource resource(int resId) { return new ImageSource(resId); }
/** * 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. * @param bitmap bitmap to be displayed. */ public static ImageSource cachedBitmap(Bitmap bitmap) { if (bitmap == null) { throw new NullPointerException("Bitmap must not be null"); } return new ImageSource(bitmap, true); }
/** * Provide a loaded bitmap for display. * @param bitmap bitmap to be displayed. */ public static ImageSource bitmap(Bitmap bitmap) { if (bitmap == null) { throw new NullPointerException("Bitmap must not be null"); } return new ImageSource(bitmap, false); }
/** * Create an instance from a URI. * @param uri image URI. */ public static ImageSource uri(Uri uri) { if (uri == null) { throw new NullPointerException("Uri must not be null"); } return new ImageSource(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. * @param uri image URI. */ public static ImageSource uri(String uri) { if (uri == null) { throw new NullPointerException("Uri must not be null"); } if (!uri.contains("://")) { if (uri.startsWith("/")) { uri = uri.substring(1); } uri = FILE_SCHEME + uri; } return new ImageSource(Uri.parse(uri)); }