com.nostra13.universalimageloader.core.assist.FailReason.FailType Java Examples

The following examples show how to use com.nostra13.universalimageloader.core.assist.FailReason.FailType. 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: LoadAndDisplayImageTask.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
private void fireFailEvent(final FailType failType, final Throwable failCause) {
	if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return;
	Runnable r = new Runnable() {
		@Override
		public void run() {
			if (options.shouldShowImageOnFail()) {
                   Bitmap bitmapOnFaile = options.getImageBitmapOnFail(configuration.resources);
                   if (options.getDisplayer() instanceof RoundedBitmapDisplayer && bitmapOnFaile != null) {
                       int corner = ((RoundedBitmapDisplayer) options.getDisplayer()).getRoundedBitmapCorner();
                       if (corner != 0) {
                           imageAware.setImageDrawable(new RoundedBitmapDisplayer.RoundedDrawable(bitmapOnFaile, corner, 0));
                       }
                   } else {
                       imageAware.setImageDrawable(options.getImageOnFail(configuration.resources));
                   }
               }
               listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause));
		}
	};
	runTask(r, false, handler, engine);
}
 
Example #2
Source File: LoadAndDisplayImageTask.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 6 votes vote down vote up
/**
 * 图片加载失败事件处理分发
 * @param failType
 * @param failCause
 */
private void fireFailEvent(final FailType failType, final Throwable failCause) {
	if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return;
	Runnable r = new Runnable() {
		@Override
		public void run() {
			if (options.shouldShowImageOnFail()) {
				//存在图片加载失败的占位图片配置,进行设置
				imageAware.setImageDrawable(options.getImageOnFail(configuration.resources));
			}
			//进行回调图片加载失败方法
			listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause));
		}
	};
	//任务进行运行
	runTask(r, false, handler, engine);
}
 
Example #3
Source File: LoadAndDisplayImageTask.java    From candybar with Apache License 2.0 5 votes vote down vote up
private void fireFailEvent(final FailType failType, final Throwable failCause) {
    if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return;
    Runnable r = new Runnable() {
        @Override
        public void run() {
            if (options.shouldShowImageOnFail()) {
                imageAware.setImageDrawable(options.getImageOnFail(configuration.context));
            }
            listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause));
        }
    };
    runTask(r, false, handler, engine);
}
 
Example #4
Source File: LoadAndDisplayImageTask.java    From letv with Apache License 2.0 5 votes vote down vote up
private void fireFailEvent(final FailType failType, final Throwable failCause) {
    if (!this.syncLoading && !isTaskInterrupted() && !isTaskNotActual()) {
        runTask(new Runnable() {
            public void run() {
                if (LoadAndDisplayImageTask.this.options.shouldShowImageOnFail()) {
                    LoadAndDisplayImageTask.this.imageAware.setImageDrawable(LoadAndDisplayImageTask.this.options.getImageOnFail(LoadAndDisplayImageTask.this.configuration.resources));
                }
                LoadAndDisplayImageTask.this.listener.onLoadingFailed(LoadAndDisplayImageTask.this.uri, LoadAndDisplayImageTask.this.imageAware.getWrappedView(), new FailReason(failType, failCause));
            }
        }, false, this.handler, this.engine);
    }
}
 
Example #5
Source File: LoadAndDisplayImageTask.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
private void fireFailEvent(final FailType failType, final Throwable failCause) {
	if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return;
	Runnable r = new Runnable() {
		@Override
		public void run() {
			if (options.shouldShowImageOnFail()) {
				imageAware.setImageDrawable(options.getImageOnFail(configuration.resources));
			}
			listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause));
		}
	};
	runTask(r, false, handler, engine);
}
 
Example #6
Source File: LoadAndDisplayImageTask.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
private void fireFailEvent(final FailType failType, final Throwable failCause) {
	if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return;
	Runnable r = new Runnable() {
		@Override
		public void run() {
			if (options.shouldShowImageOnFail()) {
				imageAware.setImageDrawable(options.getImageOnFail(configuration.resources));
			}
			listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause));
		}
	};
	runTask(r, false, handler, engine);
}
 
Example #7
Source File: LoadAndDisplayImageTask.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
private void fireFailEvent(final FailType failType, final Throwable failCause) {
	if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return;
	Runnable r = new Runnable() {
		@Override
		public void run() {
			if (options.shouldShowImageOnFail()) {
				imageAware.setImageDrawable(options.getImageOnFail(configuration.resources));
			}
			listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause));
		}
	};
	runTask(r, false, handler, engine);
}
 
Example #8
Source File: LoadAndDisplayImageTask.java    From letv with Apache License 2.0 4 votes vote down vote up
private Bitmap tryLoadBitmap() throws TaskCancelledException {
    Bitmap bitmap = null;
    if (this.thumbnailUtils != null && this.uri.startsWith("LetvThumbnailUtils")) {
        bitmap = this.thumbnailUtils.getThumbnailBitmap(this.uri.replace("LetvThumbnailUtils", ""));
        if (bitmap != null) {
            return bitmap;
        }
    }
    try {
        File imageFile = this.configuration.diskCache.get(this.uri);
        if (imageFile != null && imageFile.exists()) {
            L.d(LOG_LOAD_IMAGE_FROM_DISK_CACHE, this.memoryCacheKey);
            this.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, this.memoryCacheKey);
            this.loadedFrom = LoadedFrom.NETWORK;
            String imageUriForDecoding = this.uri;
            if (this.options.isCacheOnDisk() && tryCacheImageOnDisk()) {
                imageFile = this.configuration.diskCache.get(this.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);
            }
        }
    } catch (IllegalStateException e) {
        fireFailEvent(FailType.NETWORK_DENIED, null);
    } catch (TaskCancelledException e2) {
        throw e2;
    } catch (IOException e3) {
        L.e(e3);
        fireFailEvent(FailType.IO_ERROR, e3);
    } catch (OutOfMemoryError e4) {
        L.e(e4);
        fireFailEvent(FailType.OUT_OF_MEMORY, e4);
    } catch (Throwable e5) {
        L.e(e5);
        fireFailEvent(FailType.UNKNOWN, e5);
    }
    return bitmap;
}