Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example borrowed from https://github.com/nostra13/Android-Universal-Image-Loader
- // File: library/src/main/java/com/nostra13/universalimageloader/core/LoadAndDisplayImageTask.java
- private Bitmap tryLoadBitmap() throws TaskCancelledException {
- Bitmap bitmap = null;
- catch (IllegalStateException e) { fireFailEvent(FailType.NETWORK_DENIED, null); }
- catch (TaskCancelledException e) { throw e; }
- catch (IOException e) { L.e(e); fireFailEvent(FailType.IO_ERROR, e); }
- catch (OutOfMemoryError e) { L.e(e); fireFailEvent(FailType.OUT_OF_MEMORY, e); }
- catch (Throwable e) { L.e(e); fireFailEvent(FailType.UNKNOWN, e); }
- File imageFile = configuration.diskCache.get(uri);
- if (imageFile != null && imageFile.exists() && imageFile.length() > 0) {
- L.d(LOG_LOAD_IMAGE_FROM_DISK_CACHE, memoryCacheKey);
- loadedFrom = LoadedFrom.DISC_CACHE;
- checkTaskNotActual();
- bitmap = decodeImage(Scheme.FILE.wrap(imageFile.getAbsolutePath()));
- }
- if (bitmap == null || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) {
- L.d(LOG_LOAD_IMAGE_FROM_NETWORK, memoryCacheKey);
- loadedFrom = LoadedFrom.NETWORK;
- String imageUriForDecoding = uri;
- if (options.isCacheOnDisk() && tryCacheImageOnDisk()) {
- imageFile = configuration.diskCache.get(uri);
- if (imageFile != null) {
- imageUriForDecoding = Scheme.FILE.wrap(imageFile.getAbsolutePath());
- }
- }
- checkTaskNotActual();
- bitmap = decodeImage(imageUriForDecoding);
- if (bitmap == null || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) {
- fireFailEvent(FailType.DECODING_ERROR, null);
- }
- }
- return bitmap;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement