com.android.volley.toolbox.ImageLoader.ImageCache Java Examples

The following examples show how to use com.android.volley.toolbox.ImageLoader.ImageCache. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BitmapDecoder.java    From volley with Apache License 2.0 5 votes vote down vote up
/**
 * decode bitmap from resource
 * 
 * @param resId
 * @return
 */
public static Bitmap getBitmapFromRes(Context context, ImageCache cache, int resId, int maxWidth, int maxHeight) {
    Bitmap bitmap = null;
    if (cache != null) {
        bitmap = cache.getBitmap(SCHEME_RES + resId);
    }
    if (bitmap == null) {
        bitmap = inputStream2Bitmap(context, SCHEME_RES + resId, getInputStream(context, SCHEME_RES + resId), Config.RGB_565, maxWidth, maxHeight);
        if (cache != null && bitmap != null) {
            cache.putBitmap(SCHEME_RES + resId, bitmap);
        }
    }
    return bitmap;
}
 
Example #2
Source File: BitmapDecoder.java    From volley with Apache License 2.0 5 votes vote down vote up
/**
 * decode bitmap from asset
 * bitmap getBitmapFromAsset
 * 
 * @param filePath
 * @return
 * @since 3.6
 */
public static Bitmap getBitmapFromAsset(Context context, ImageCache cache, String filePath, int maxWidth, int maxHeight) {
    Bitmap bitmap = null;
    if (cache != null) {
        bitmap = cache.getBitmap(SCHEME_ASSET + filePath);
    }
    if (bitmap == null) {
        bitmap = inputStream2Bitmap(context, SCHEME_ASSET + filePath, getInputStream(context, SCHEME_ASSET + filePath), Config.RGB_565, maxWidth, maxHeight);
        if (cache != null && bitmap != null) {
            cache.putBitmap(SCHEME_ASSET + filePath, bitmap);
        }
    }
    return bitmap;
}
 
Example #3
Source File: BitmapDecoder.java    From volley with Apache License 2.0 5 votes vote down vote up
/**
 * decode bitmap from content
 * getStreamFromContent
 * 
 * @param imageUri
 * @return
 * @since 3.6
 */
public static Bitmap getBitmapFromContent(Context context, ImageCache cache, String imageUri, int maxWidth, int maxHeight) {
    Bitmap bitmap = null;
    if (cache != null) {
        bitmap = cache.getBitmap(SCHEME_CONTENT + imageUri);
    }
    if (bitmap == null) {
        bitmap = inputStream2Bitmap(context, SCHEME_CONTENT + imageUri, getInputStream(context, SCHEME_CONTENT + imageUri), Config.RGB_565, maxWidth, maxHeight);
        if (cache != null && bitmap != null) {
            cache.putBitmap(SCHEME_CONTENT + imageUri, bitmap);
        }
    }
    return bitmap;
}
 
Example #4
Source File: BitmapDecoder.java    From volley with Apache License 2.0 5 votes vote down vote up
/**
 * decode bitmap from sdcard
 * getBitmapFromFile
 * @param cache
 * @param path
 * @param maxWidth
 * @param maxHeight
 * @return
 * @since 3.5
 */
public static Bitmap getBitmapFromFile(ImageCache cache, String path, int maxWidth, int maxHeight) {
    Bitmap bitmap = null;
    if (cache != null) {
        bitmap = cache.getBitmap(path);
    }
    if (bitmap == null) {
        bitmap = inputStream2Bitmap(null, path, getInputStream(null, path), Config.RGB_565, maxWidth, maxHeight);
        if (cache != null && bitmap != null) {
            cache.putBitmap(path, bitmap);
        }
    }
    return bitmap;
}