本文整理汇总了Java中com.androidnetworking.internal.ANImageLoader.ImageContainer方法的典型用法代码示例。如果您正苦于以下问题:Java ANImageLoader.ImageContainer方法的具体用法?Java ANImageLoader.ImageContainer怎么用?Java ANImageLoader.ImageContainer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.androidnetworking.internal.ANImageLoader
的用法示例。
在下文中一共展示了ANImageLoader.ImageContainer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadImageIfNecessary
import com.androidnetworking.internal.ANImageLoader; //导入方法依赖的package包/类
void loadImageIfNecessary(final boolean isInLayoutPass) {
int width = getWidth();
int height = getHeight();
ScaleType scaleType = getScaleType();
boolean wrapWidth = false, wrapHeight = false;
if (getLayoutParams() != null) {
wrapWidth = getLayoutParams().width == ViewGroup.LayoutParams.WRAP_CONTENT;
wrapHeight = getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT;
}
boolean isFullyWrapContent = wrapWidth && wrapHeight;
if (width == 0 && height == 0 && !isFullyWrapContent) {
return;
}
if (TextUtils.isEmpty(mUrl)) {
if (mImageContainer != null) {
mImageContainer.cancelRequest();
mImageContainer = null;
}
setDefaultImageOrNull();
return;
}
if (mImageContainer != null && mImageContainer.getRequestUrl() != null) {
if (mImageContainer.getRequestUrl().equals(mUrl)) {
return;
} else {
mImageContainer.cancelRequest();
setDefaultImageOrNull();
}
}
int maxWidth = wrapWidth ? 0 : width;
int maxHeight = wrapHeight ? 0 : height;
ANImageLoader.ImageContainer newContainer = ANImageLoader.getInstance().get(mUrl,
new ANImageLoader.ImageListener() {
@Override
public void onResponse(final ANImageLoader.ImageContainer response,
boolean isImmediate) {
if (isImmediate && isInLayoutPass) {
post(new Runnable() {
@Override
public void run() {
onResponse(response, false);
}
});
return;
}
if (response.getBitmap() != null) {
setImageBitmap(response.getBitmap());
} else if (mDefaultImageId != 0) {
setImageResource(mDefaultImageId);
}
}
@Override
public void onError(ANError error) {
if (mErrorImageId != 0) {
setImageResource(mErrorImageId);
}
}
}, maxWidth, maxHeight, scaleType);
mImageContainer = newContainer;
}
示例2: loadImageIfNecessary
import com.androidnetworking.internal.ANImageLoader; //导入方法依赖的package包/类
void loadImageIfNecessary(final boolean isInLayoutPass) {
int width = getWidth();
int height = getHeight();
ImageView.ScaleType scaleType = getScaleType();
boolean wrapWidth = false, wrapHeight = false;
if (getLayoutParams() != null) {
wrapWidth = getLayoutParams().width == ViewGroup.LayoutParams.WRAP_CONTENT;
wrapHeight = getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT;
}
boolean isFullyWrapContent = wrapWidth && wrapHeight;
if (width == 0 && height == 0 && !isFullyWrapContent) {
return;
}
if (TextUtils.isEmpty(mUrl)) {
if (mImageContainer != null) {
mImageContainer.cancelRequest();
mImageContainer = null;
}
setDefaultImageOrNull();
return;
}
if (mImageContainer != null && mImageContainer.getRequestUrl() != null) {
if (mImageContainer.getRequestUrl().equals(mUrl)) {
return;
} else {
mImageContainer.cancelRequest();
setDefaultImageOrNull();
}
}
int maxWidth = wrapWidth ? 0 : width;
int maxHeight = wrapHeight ? 0 : height;
ANImageLoader.ImageContainer newContainer = ANImageLoader.getInstance().get(mUrl,
new ANImageLoader.ImageListener() {
@Override
public void onResponse(final ANImageLoader.ImageContainer response,
boolean isImmediate) {
if (isImmediate && isInLayoutPass) {
post(new Runnable() {
@Override
public void run() {
onResponse(response, false);
}
});
return;
}
if (response.getBitmap() != null) {
setImageBitmap(response.getBitmap());
} else if (mDefaultImageId != 0) {
setImageResource(mDefaultImageId);
}
}
@Override
public void onError(ANError error) {
if (mErrorImageId != 0) {
setImageResource(mErrorImageId);
}
}
}, maxWidth, maxHeight, scaleType);
mImageContainer = newContainer;
}