Java Code Examples for com.nostra13.universalimageloader.utils.L#e()

The following examples show how to use com.nostra13.universalimageloader.utils.L#e() . 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: DefaultConfigurationFactory.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
/**
 * Creates default implementation of {@link DiskCache} depends on incoming parameters
 */
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator,
		long diskCacheSize, int diskCacheFileCount) {
	File reserveCacheDir = createReserveDiskCacheDir(context);
	if (diskCacheSize > 0 || diskCacheFileCount > 0) {
		File individualCacheDir = StorageUtils.getIndividualCacheDirectory(context);
		try {
			return new LruDiskCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
					diskCacheFileCount);
		} catch (IOException e) {
			L.e(e);
			// continue and create unlimited cache
		}
	}
	File cacheDir = StorageUtils.getCacheDirectory(context);
	return new UnlimitedDiskCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
}
 
Example 2
Source File: DefaultConfigurationFactory.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 6 votes vote down vote up
/**
 * 默认图片 本地路径缓存
 * Creates default implementation of {@link DiskCache} depends on incoming parameters
 */
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator,
		long diskCacheSize, int diskCacheFileCount) {
	//创建备用缓存文件
	File reserveCacheDir = createReserveDiskCacheDir(context);
	if (diskCacheSize > 0 || diskCacheFileCount > 0) {
		File individualCacheDir = StorageUtils.getIndividualCacheDirectory(context);
		try {
			//创建本地文件系统缓存器
			return new LruDiskCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
					diskCacheFileCount);
		} catch (IOException e) {
			L.e(e);
			// continue and create unlimited cache
		}
	}
	//创建无限制的文件缓存器
	File cacheDir = StorageUtils.getCacheDirectory(context);
	return new UnlimitedDiskCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
}
 
Example 3
Source File: BaseImageDecoder.java    From candybar with Apache License 2.0 5 votes vote down vote up
/**
 * Decodes image from URI into {@link Bitmap}. Image is scaled close to incoming {@linkplain ImageSize target size}
 * during decoding (depend on incoming parameters).
 *
 * @param decodingInfo Needed data for decoding image
 * @return Decoded bitmap
 * @throws IOException                   if some I/O exception occurs during image reading
 * @throws UnsupportedOperationException if image URI has unsupported scheme(protocol)
 */
@Override
public Bitmap decode(ImageDecodingInfo decodingInfo) throws IOException {
    Bitmap decodedBitmap;
    ImageFileInfo imageInfo;

    InputStream imageStream = getImageStream(decodingInfo);
    if (imageStream == null) {
        L.e(ERROR_NO_IMAGE_STREAM, decodingInfo.getImageKey());
        return null;
    }
    try {
        imageInfo = defineImageSizeAndRotation(imageStream, decodingInfo);
        imageStream = resetStream(imageStream, decodingInfo);
        Options decodingOptions = prepareDecodingOptions(imageInfo.imageSize, decodingInfo);
        decodedBitmap = BitmapFactory.decodeStream(imageStream, null, decodingOptions);
    } finally {
        IoUtils.closeSilently(imageStream);
    }

    if (decodedBitmap == null) {
        L.e(ERROR_CANT_DECODE_IMAGE, decodingInfo.getImageKey());
    } else {
        decodedBitmap = considerExactScaleAndOrientatiton(decodedBitmap, decodingInfo, imageInfo.exif.rotation,
                imageInfo.exif.flipHorizontal);
    }
    return decodedBitmap;
}
 
Example 4
Source File: LruDiskCache.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
@Override
public void close() {
	try {
		cache.close();
	} catch (IOException e) {
		L.e(e);
	}
	cache = null;
}
 
Example 5
Source File: BaseImageDecoder.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
/**
 * Decodes image from URI into {@link Bitmap}. Image is scaled close to incoming {@linkplain ImageSize target size}
 * during decoding (depend on incoming parameters).
 *
 * @param decodingInfo Needed data for decoding image
 * @return Decoded bitmap
 * @throws IOException                   if some I/O exception occurs during image reading
 * @throws UnsupportedOperationException if image URI has unsupported scheme(protocol)
 */
@Override
public Bitmap decode(ImageDecodingInfo decodingInfo) throws IOException {
    Bitmap decodedBitmap;
    ImageFileInfo imageInfo;

    InputStream imageStream = getImageStream(decodingInfo);
    if (imageStream == null) {
        L.e(ERROR_NO_IMAGE_STREAM, decodingInfo.getImageKey());
        return null;
    }
    try {
        imageInfo = defineImageSizeAndRotation(imageStream, decodingInfo);
        imageStream = resetStream(imageStream, decodingInfo);
        Options decodingOptions = prepareDecodingOptions(imageInfo.imageSize, decodingInfo);
        decodedBitmap = BitmapFactory.decodeStream(imageStream, null, decodingOptions);
    } finally {
        IoUtils.closeSilently(imageStream);
    }

    if (decodedBitmap == null) {
        L.e(ERROR_CANT_DECODE_IMAGE, decodingInfo.getImageKey());
    } else {
        decodedBitmap = considerExactScaleAndOrientatiton(decodedBitmap, decodingInfo, imageInfo.exif.rotation,
                imageInfo.exif.flipHorizontal);
    }
    return decodedBitmap;
}
 
Example 6
Source File: LoadAndDisplayImageTask.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/** @return <b>true</b> - if task should be interrupted; <b>false</b> - otherwise */
private boolean delayIfNeed() {
	if (options.shouldDelayBeforeLoading()) {
		L.d(LOG_DELAY_BEFORE_LOADING, options.getDelayBeforeLoading(), memoryCacheKey);
		try {
			Thread.sleep(options.getDelayBeforeLoading());
		} catch (InterruptedException e) {
			L.e(LOG_TASK_INTERRUPTED, memoryCacheKey);
			return true;
		}
		return isTaskNotActual();
	}
	return false;
}
 
Example 7
Source File: LruDiscCache.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public boolean remove(String s)
{
    boolean flag;
    try
    {
        flag = cache.c(a(s));
    }
    catch (IOException ioexception)
    {
        L.e(ioexception);
        return false;
    }
    return flag;
}
 
Example 8
Source File: LruDiscCache.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
@Override
public void close() {
	try {
		cache.close();
	} catch (IOException e) {
		L.e(e);
	}
	cache = null;
}
 
Example 9
Source File: l.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private boolean e()
{
    Object aobj[] = new Object[1];
    aobj[0] = H;
    L.d("Cache image on disk [%s]", aobj);
    boolean flag;
    int i1;
    int j1;
    Object aobj1[];
    try
    {
        flag = f();
    }
    catch (IOException ioexception)
    {
        L.e(ioexception);
        return false;
    }
    if (!flag)
    {
        break MISSING_BLOCK_LABEL_85;
    }
    i1 = C.d;
    j1 = C.e;
    if (i1 <= 0 && j1 <= 0)
    {
        break MISSING_BLOCK_LABEL_85;
    }
    aobj1 = new Object[1];
    aobj1[0] = H;
    L.d("Resize image in disk cache [%s]", aobj1);
    a(i1, j1);
    return flag;
}
 
Example 10
Source File: LruDiskCache.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化本地文件 图片缓存器
 * @param cacheDir          图片缓存路径
 * @param reserveCacheDir     备用图片缓存路径
 * @param cacheMaxSize        最大缓存大小
 * @param cacheMaxFileCount    最大缓存图片数量
 * @throws IOException
 */
private void initCache(File cacheDir, File reserveCacheDir, long cacheMaxSize, int cacheMaxFileCount)
		throws IOException {
	try {
		cache = DiskLruCache.open(cacheDir, 1, 1, cacheMaxSize, cacheMaxFileCount);
	} catch (IOException e) {
		L.e(e);
		if (reserveCacheDir != null) {
			initCache(reserveCacheDir, null, cacheMaxSize, cacheMaxFileCount);
		}
		if (cache == null) {
			throw e; //new RuntimeException("Can't initialize disk cache", e);
		}
	}
}
 
Example 11
Source File: LoadAndDisplayImageTask.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
/** @return <b>true</b> - if task should be interrupted; <b>false</b> - otherwise */
private boolean delayIfNeed() {
	if (options.shouldDelayBeforeLoading()) {
		L.d(LOG_DELAY_BEFORE_LOADING, options.getDelayBeforeLoading(), memoryCacheKey);
		try {
			Thread.sleep(options.getDelayBeforeLoading());
		} catch (InterruptedException e) {
			L.e(LOG_TASK_INTERRUPTED, memoryCacheKey);
			return true;
		}
		return isTaskNotActual();
	}
	return false;
}
 
Example 12
Source File: Md5FileNameGenerator.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
private byte[] getMD5(byte[] data) {
	byte[] hash = null;
	try {
		MessageDigest digest = MessageDigest.getInstance(HASH_ALGORITHM);
		digest.update(data);
		hash = digest.digest();
	} catch (NoSuchAlgorithmException e) {
		L.e(e);
	}
	return hash;
}
 
Example 13
Source File: LruDiskCache.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
/**
 * 进行关闭缓存
 */
@Override
public void close() {
	try {
		cache.close();
	} catch (IOException e) {
		L.e(e);
	}
	cache = null;
}
 
Example 14
Source File: LruDiskCache.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
@Override
public File get(String imageUri) {
	DiskLruCache.Snapshot snapshot = null;
	try {
		snapshot = cache.get(getKey(imageUri));
		return snapshot == null ? null : snapshot.getFile(0);
	} catch (IOException e) {
		L.e(e);
		return null;
	} finally {
		if (snapshot != null) {
			snapshot.close();
		}
	}
}
 
Example 15
Source File: LoadAndDisplayImageTask.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
/** Decodes image file into Bitmap, resize it and save it back */
private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException {
	// Decode image file, compress and re-save it
	boolean saved = false;
	File targetFile = configuration.diskCache.get(uri);
	if (targetFile != null && targetFile.exists()) {
		ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight);
		DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options)
				.imageScaleType(ImageScaleType.IN_SAMPLE_INT).build();
		ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey,
				Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE,
				getDownloader(), specialOptions);
		Bitmap bmp = decoder.decode(decodingInfo);
		if (bmp != null && configuration.processorForDiskCache != null) {
			L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey);
			bmp = configuration.processorForDiskCache.process(bmp);
			if (bmp == null) {
				L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey);
			}
		}
		if (bmp != null) {
			saved = configuration.diskCache.save(uri, bmp);
			bmp.recycle();
		}
	}
	return saved;
}
 
Example 16
Source File: LruDiscCache.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
@Override
public File get(String imageUri) {
	DiskLruCache.Snapshot snapshot = null;
	try {
		snapshot = cache.get(getKey(imageUri));
		return snapshot == null ? null : snapshot.getFile(0);
	} catch (IOException e) {
		L.e(e);
		return null;
	} finally {
		if (snapshot != null) {
			snapshot.close();
		}
	}
}
 
Example 17
Source File: LruDiskCache.java    From candybar with Apache License 2.0 5 votes vote down vote up
@Override
public void close() {
    try {
        cache.close();
    } catch (IOException e) {
        L.e(e);
    }
    cache = null;
}
 
Example 18
Source File: LruDiskCache.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
private void initCache(File cacheDir, File reserveCacheDir, long cacheMaxSize, int cacheMaxFileCount)
		throws IOException {
	try {
		cache = DiskLruCache.open(cacheDir, 1, 1, cacheMaxSize, cacheMaxFileCount);
	} catch (IOException e) {
		L.e(e);
		if (reserveCacheDir != null) {
			initCache(reserveCacheDir, null, cacheMaxSize, cacheMaxFileCount);
		}
		if (cache == null) {
			throw e; //new RuntimeException("Can't initialize disk cache", e);
		}
	}
}
 
Example 19
Source File: ImageViewAware.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
private static int getImageViewFieldValue(Object object, String fieldName) {
	int value = 0;
	try {
		Field field = ImageView.class.getDeclaredField(fieldName);
		field.setAccessible(true);
		int fieldValue = (Integer) field.get(object);
		if (fieldValue > 0 && fieldValue < Integer.MAX_VALUE) {
			value = fieldValue;
		}
	} catch (Exception e) {
		L.e(e);
	}
	return value;
}
 
Example 20
Source File: DefaultConfigurationFactory.java    From letv with Apache License 2.0 5 votes vote down vote up
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator, long diskCacheSize, int diskCacheFileCount) {
    File reserveCacheDir = createReserveDiskCacheDir(context);
    if (diskCacheSize > 0 || diskCacheFileCount > 0) {
        try {
            return new LruDiscCache(StorageUtils.getIndividualCacheDirectory(context), reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize, diskCacheFileCount);
        } catch (IOException e) {
            L.e(e);
        }
    }
    return new UnlimitedDiscCache(StorageUtils.getCacheDirectory(context), reserveCacheDir, diskCacheFileNameGenerator);
}