use of com.nostra13.universalimageloader.core.assist.FailReason.FailType in project Android-Universal-Image-Loader by nostra13.
the class LoadAndDisplayImageTask method fireFailEvent.
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);
}
use of com.nostra13.universalimageloader.core.assist.FailReason.FailType in project QuickAndroid by ImKarl.
the class DefaultImage method createQAImageLoadingListener.
/**
* 创建图片加载监听器
* @param view
* @param listener
* @return
*/
@SuppressWarnings("rawtypes")
private QAImageLoadingListener createQAImageLoadingListener(View view, final QAImageCallback listener) {
return new QAImageLoadingListener<View>(view) {
@Override
public void onLoadingCancelled(View view, String imageUri) {
if (listener != null) {
listener.onCancel(imageUri, view);
}
}
@Override
public void onLoadingComplete(View view, String imageUri, Bitmap loadedImage) {
if (listener != null) {
listener.onSuccess(imageUri, view, loadedImage);
}
}
@Override
public void onLoadingFailed(View view, String imageUri, FailReason failReason) {
if (listener != null) {
FailType type = failReason.getType();
int code = QAException.CODE_UNKNOW;
if (type == FailType.IO_ERROR) {
code = QAException.CODE_IO_FILE;
} else if (type == FailType.DECODING_ERROR) {
code = QAException.CODE_DECODE;
} else if (type == FailType.NETWORK_DENIED) {
code = QAException.CODE_NETWORK;
} else if (type == FailType.OUT_OF_MEMORY) {
code = QAException.CODE_OOM;
} else if (type == FailType.UNKNOWN) {
code = QAException.CODE_UNKNOW;
}
QAImageException exception = new QAImageException(code, failReason.getCause());
listener.onFail(imageUri, view, exception);
}
}
@Override
public void onLoadingStarted(View view, String imageUri) {
if (listener != null) {
listener.onStart(imageUri, view);
}
}
};
}
Aggregations