1 package com.android.ex.photo.loaders; 2 3 import android.content.res.Resources; 4 import android.graphics.Bitmap; 5 import android.graphics.drawable.BitmapDrawable; 6 import android.graphics.drawable.Drawable; 7 8 public interface PhotoBitmapLoaderInterface { 9 setPhotoUri(String photoUri)10 public void setPhotoUri(String photoUri); 11 forceLoad()12 public void forceLoad(); 13 14 public static class BitmapResult { 15 public static final int STATUS_SUCCESS = 0; 16 public static final int STATUS_EXCEPTION = 1; 17 18 public Drawable drawable; 19 public Bitmap bitmap; 20 public int status; 21 22 /** 23 * Returns a drawable to be used in the {@link com.android.ex.photo.views.PhotoView}. 24 * Should return null if the drawable is not ready to be shown (for instance, if 25 * the underlying bitmap is null). 26 */ getDrawable(Resources resources)27 public Drawable getDrawable(Resources resources) { 28 if (resources == null) { 29 throw new IllegalArgumentException("resources can not be null!"); 30 } 31 32 if (drawable != null) { 33 return drawable; 34 } 35 36 // Don't create a new drawable if there's no bitmap. PhotoViewFragment regards 37 // a null drawable as a signal to keep showing the loading stuff. 38 // b/12348405. 39 if (bitmap == null) { 40 return null; 41 } 42 43 return new BitmapDrawable(resources, bitmap); 44 } 45 } 46 } 47