use of cn.jeesoft.qa.error.QAImageException 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