当前位置: 首页>>代码示例>>Java>>正文


Java ANImageLoader类代码示例

本文整理汇总了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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:AndroidNetworking.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:AndroidNetworking.java

示例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();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:AndroidNetworking.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:AndroidNetworking.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:70,代码来源:ANImageView.java

示例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));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:MainActivity.java

示例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
    );

}
 
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:65,代码来源:NetworkImageView.java

示例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;
}
 
开发者ID:amitshekhariitbhu,项目名称:Fast-Android-Networking,代码行数:70,代码来源:ANImageView.java


注:本文中的com.androidnetworking.internal.ANImageLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。