本文整理汇总了Java中com.androidnetworking.internal.ANImageLoader类的典型用法代码示例。如果您正苦于以下问题:Java ANImageLoader类的具体用法?Java ANImageLoader怎么用?Java ANImageLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ANImageLoader类属于com.androidnetworking.internal包,在下文中一共展示了ANImageLoader类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import com.androidnetworking.internal.ANImageLoader; //导入依赖的package包/类
/**
* Initializes AndroidNetworking with the specified config.
*
* @param context The context
* @param okHttpClient The okHttpClient
*/
public static void initialize(Context context, OkHttpClient okHttpClient) {
if (okHttpClient != null && okHttpClient.cache() == null) {
okHttpClient = okHttpClient
.newBuilder()
.cache(Utils.getCache(context.getApplicationContext(),
ANConstants.MAX_CACHE_SIZE, ANConstants.CACHE_DIR_NAME))
.build();
}
InternalNetworking.setClient(okHttpClient);
ANRequestQueue.initialize();
ANImageLoader.initialize();
}
示例2: evictBitmap
import com.androidnetworking.internal.ANImageLoader; //导入依赖的package包/类
/**
* Method to evict a bitmap with given key from LruCache
*
* @param key The key of the bitmap
*/
public static void evictBitmap(String key) {
final ANImageLoader.ImageCache imageCache = ANImageLoader.getInstance().getImageCache();
if (imageCache != null && key != null) {
imageCache.evictBitmap(key);
}
}
示例3: evictAllBitmap
import com.androidnetworking.internal.ANImageLoader; //导入依赖的package包/类
/**
* Method to clear LruCache
*/
public static void evictAllBitmap() {
final ANImageLoader.ImageCache imageCache = ANImageLoader.getInstance().getImageCache();
if (imageCache != null) {
imageCache.evictAllBitmap();
}
}
示例4: setBitmapDecodeOptions
import com.androidnetworking.internal.ANImageLoader; //导入依赖的package包/类
/**
* Method to set decodeOptions
*
* @param decodeOptions The decode config for Bitmaps
*/
public static void setBitmapDecodeOptions(BitmapFactory.Options decodeOptions) {
if (decodeOptions != null) {
ANImageLoader.getInstance().setBitmapDecodeOptions(decodeOptions);
}
}
示例5: 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;
}
示例6: loadImageFromImageLoader
import com.androidnetworking.internal.ANImageLoader; //导入依赖的package包/类
public void loadImageFromImageLoader(View view) {
ANImageLoader.getInstance().get(URL_IMAGE_LOADER, ANImageLoader.getImageListener(imageView,
R.drawable.ic_toys_black_24dp, R.drawable.ic_error_outline_black_24dp));
}
示例7: loadImage
import com.androidnetworking.internal.ANImageLoader; //导入依赖的package包/类
private void loadImage(final boolean isInLayoutPass) {
final int width = getWidth();
final int height = getHeight();
boolean wrapWidth = false, wrapHeight = false;
if(getLayoutParams() != null) {
wrapWidth = getLayoutParams().width == ViewGroup.LayoutParams.WRAP_CONTENT;
wrapHeight = getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT;
}
if(width == 0 && height == 0 && !(wrapWidth && wrapHeight)) {
//Can't display the image as not size
return;
}
if(TextUtils.isEmpty(mUrl)) {
if(mImageContainer != null) {
mImageContainer.cancelRequest();
mImageContainer = null;
}
displayDefaultImage();
return;
}
if(mImageContainer != null && mImageContainer.getRequestUrl() != null) {
if(mImageContainer.getRequestUrl().equals(mUrl)) {
return;
} else {
mImageContainer.cancelRequest();
}
}
final int maxWidth = wrapWidth ? 0 : width;
final int maxHeight = wrapHeight ? 0 : height;
final ScaleType scaleType = getScaleType();
mImageContainer = ANImageLoader.getInstance().get(mUrl,
new ANImageLoader.ImageListener() {
@Override
public void onResponse(final ANImageLoader.ImageContainer response,
boolean isImmediate) {
if(isImmediate && isInLayoutPass) {
post(() -> onResponse(response, false));
return;
}
if(response.getBitmap() != null) {
setImageBitmap(response.getBitmap());
} else if(mDefaultImageResId != 0) {
displayDefaultImage();
}
}
@Override
public void onError(ANError error) {
if(mErrorImageResId != 0) {
setImageResource(mErrorImageResId);
}
}
}, maxWidth, maxHeight, scaleType
);
}
示例8: 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;
}