/**
* Uses the configuration previously applied using this ImageLoader builder to download a
* resource asynchronously and notify the result to the listener.
*/
private void loadImage() {
List<Transformation> transformations = getTransformations();
boolean hasUrl = url != null;
boolean hasResourceId = resourceId != null;
boolean hasPlaceholder = placeholderId != null;
ListenerTarget listenerTarget = getLinearTarget(listener);
if (hasUrl) {
RequestCreator bitmapRequest = Picasso.with(context).load(url).tag(PICASSO_IMAGE_LOADER_TAG);
applyPlaceholder(bitmapRequest).resize(size, size)
.transform(transformations)
.into(listenerTarget);
} else if (hasResourceId || hasPlaceholder) {
Resources resources = context.getResources();
Drawable placeholder = null;
Drawable drawable = null;
if (hasPlaceholder) {
placeholder = resources.getDrawable(placeholderId);
listenerTarget.onPrepareLoad(placeholder);
}
if (hasResourceId) {
drawable = resources.getDrawable(resourceId);
listenerTarget.onDrawableLoad(drawable);
}
} else {
throw new IllegalArgumentException(
"Review your request, you are trying to load an image without a url or a resource id.");
}
}
PicassoImageLoader.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:Nox
作者:
评论列表
文章目录