Search in sources :

Example 36 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project AndLang by wugemu.

the class BaseLangApplication method initImageLoad.

private void initImageLoad() {
    // 配置uil工具
    File cacheDir = StorageUtils.getOwnCacheDirectory(getApplicationContext(), tmpImageDir);
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).memoryCacheExtraOptions(480, // default = device screen dimensions
    800).threadPriority(// default
    Thread.NORM_PRIORITY - 1).tasksProcessingOrder(// default
    QueueProcessingType.FIFO).threadPoolSize(3).denyCacheImageMultipleSizesInMemory().memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024).memoryCacheSizePercentage(// default
    13).diskCache(new UnlimitedDiskCache(cacheDir)).diskCacheSize(// 缓冲大小
    50 * 1024 * 1024).diskCacheFileCount(// 缓冲文件数目
    100).diskCacheFileNameGenerator(// default
    new HashCodeFileNameGenerator()).imageDownloader(// default
    new BaseImageDownloader(this)).defaultDisplayImageOptions(// default
    DisplayImageOptions.createSimple()).writeDebugLogs().build();
    // 2.单例ImageLoader类的初始化
    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.init(config);
    ImageLoadUtils.setImageSetter(new IInnerImageSetter() {

        @Override
        public <IMAGE extends ImageView> void doLoadImageUrl(@NonNull IMAGE view, @Nullable String url) {
            if (!BaseLangUtil.isEmpty(url)) {
                if (url.toLowerCase().contains(".gif")) {
                    GlideUtil.getInstance().displayGif(getApplicationContext(), url, view);
                } else {
                    GlideUtil.getInstance().display(getApplicationContext(), url, view);
                }
            }
        }

        @Override
        public <IMAGE extends ImageView> void doLoadImageUrlCenterCrop(@NonNull IMAGE view, @Nullable String url) {
            if (!BaseLangUtil.isEmpty(url)) {
                if (url.toLowerCase().contains(".gif")) {
                    GlideUtil.getInstance().displayGifCenterCrop(getApplicationContext(), url, view);
                } else {
                    GlideUtil.getInstance().displayCenterCrop(getApplicationContext(), url, view);
                }
            }
        }

        @Override
        public <IMAGE extends ImageView> void doLoadImageUrlFitCenter(@NonNull IMAGE view, @Nullable String url) {
            if (!BaseLangUtil.isEmpty(url)) {
                if (url.toLowerCase().contains(".gif")) {
                    GlideUtil.getInstance().displayGifFitCenter(getApplicationContext(), url, view);
                } else {
                    GlideUtil.getInstance().displayFitCenter(getApplicationContext(), url, view);
                }
            }
        }

        @Override
        public <IMAGE extends ImageView> void doLoadCircleImageUrl(@NonNull IMAGE view, @Nullable String url) {
            if (!BaseLangUtil.isEmpty(url)) {
                if (url.toLowerCase().contains(".gif")) {
                    GlideUtil.getInstance().displayGif(getApplicationContext(), url, view);
                } else {
                    GlideUtil.getInstance().displayHead(getApplicationContext(), url, view);
                }
            }
        }

        @Override
        public <IMAGE extends ImageView> void doLoadImageRound(@NonNull IMAGE view, @Nullable String url, float round) {
            if (!BaseLangUtil.isEmpty(url)) {
                if (url.toLowerCase().contains(".gif")) {
                    GlideUtil.getInstance().displayGif(getApplicationContext(), url, view);
                } else {
                    GlideUtil.getInstance().displayRoundImg(getApplicationContext(), url, view, round);
                }
            }
        }

        @Override
        public <IMAGE extends ImageView> void doLoadByImageLoader(@NonNull IMAGE view, @Nullable String url) {
            // 测试比较加载速度使用
            ImageLoader.getInstance().displayImage(url, view, BOUTIQUE_OPTIPON);
        }

        @Override
        public <IMAGE extends ImageView> void doLoadImageRes(@NonNull IMAGE view, @Nullable int resId) {
            GlideUtil.getInstance().displayLocRes(getApplicationContext(), resId, view);
        }
    });
}
Also used : HashCodeFileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator) IInnerImageSetter(com.example.test.andlang.util.imageload.IInnerImageSetter) UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) BaseImageDownloader(com.nostra13.universalimageloader.core.download.BaseImageDownloader) ImageLoader(com.nostra13.universalimageloader.core.ImageLoader) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 37 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project ABPlayer by winkstu.

the class VideoInfoFragment method initImageLoader.

private void initImageLoader() {
    File cacheDir = com.nostra13.universalimageloader.utils.StorageUtils.getOwnCacheDirectory(this.getActivity().getApplicationContext(), IMAGE_CACHE_PATH);
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this.getActivity()).defaultDisplayImageOptions(defaultOptions).memoryCache(new LruMemoryCache(12 * 1024 * 1024)).memoryCacheSize(12 * 1024 * 1024).discCacheSize(32 * 1024 * 1024).discCacheFileCount(100).discCache(new UnlimitedDiscCache(cacheDir)).threadPriority(Thread.NORM_PRIORITY - 2).tasksProcessingOrder(QueueProcessingType.LIFO).build();
    ImageLoader.getInstance().init(config);
}
Also used : UnlimitedDiscCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 38 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project ABPlayer by winkstu.

the class HomePageFragment2 method initImageLoader.

private void initImageLoader() {
    File cacheDir = com.nostra13.universalimageloader.utils.StorageUtils.getOwnCacheDirectory(this.getActivity().getApplicationContext(), IMAGE_CACHE_PATH);
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this.getActivity()).defaultDisplayImageOptions(defaultOptions).memoryCache(new LruMemoryCache(12 * 1024 * 1024)).memoryCacheSize(12 * 1024 * 1024).discCacheSize(32 * 1024 * 1024).discCacheFileCount(100).discCache(new UnlimitedDiscCache(cacheDir)).threadPriority(Thread.NORM_PRIORITY - 2).tasksProcessingOrder(QueueProcessingType.LIFO).build();
    ImageLoader.getInstance().init(config);
}
Also used : UnlimitedDiscCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 39 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project QuickAndroid by ImKarl.

the class QAImageLoaderConfig method getConfig.

/**
 * 获取加载配置
 * @param context
 * @param imageOnLoadingRes 加载中显示的图片
 * @param imageOnFailRes 加载失败显示的图片
 * @return
 */
public static ImageLoaderConfiguration getConfig(Context context, int imageOnLoadingRes, int imageOnFailRes) {
    DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(// 加载中
    imageOnLoadingRes).showImageForEmptyUri(// 图片Uri为空或是错误的时候显示的图片
    imageOnFailRes).showImageOnFail(// resource or drawable
    imageOnFailRes).resetViewBeforeLoading(// default
    false).delayBeforeLoading(// 加载前延迟时长
    50).cacheInMemory(// default = false 是否使用内存缓存
    true).cacheOnDisk(// default = false 是否使用文件缓存
    true).considerExifParams(// default = false
    false).imageScaleType(// default
    ImageScaleType.IN_SAMPLE_POWER_OF_2).bitmapConfig(// default
    Bitmap.Config.ARGB_8888).displayer(// default = new SimpleBitmapDisplayer()
    new FadeInBitmapDisplayer(100)).build();
    File cacheDir = new File(QAFileManager.getUsableDir(context.getPackageName()));
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(// default 线程池大小
    3).threadPriority(// default 线程优先级
    Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory().memoryCache(// 内存缓存
    new LruMemoryCache(8 * 1024 * 1024)).diskCache(// default 磁盘缓存
    new UnlimitedDiskCache(cacheDir)).diskCacheSize(// 磁盘缓存大小
    30 * 1024 * 1024).diskCacheFileNameGenerator(// default 磁盘缓存文件名
    new HashCodeFileNameGenerator()).imageDownloader(// default 图片下载器
    new BaseImageDownloader(context)).imageDecoder(// default 图片解码器
    new BaseImageDecoder(QACore.isDebug())).defaultDisplayImageOptions(// default=DisplayImageOptions.createSimple() 图片显示选项
    options).build();
    return config;
}
Also used : UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) HashCodeFileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) BaseImageDownloader(com.nostra13.universalimageloader.core.download.BaseImageDownloader) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) BaseImageDecoder(com.nostra13.universalimageloader.core.decode.BaseImageDecoder)

Example 40 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project YourAppIdea by Michenux.

the class YourApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    this.injectSelf();
    // Enable tutorial sync
    this.tutorialSyncHelper.createTutorialAccount(this);
    // Initialize Universal Image Loader
    // Create global configuration and initialize ImageLoader with this configuration
    DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(// default
    true).cacheOnDisk(// default
    true).displayer(// default SimpleBitmapDisplayer,RoundedBitmapDisplayer(10),FadeInBitmapDisplayer
    new FadeInBitmapDisplayer(5000)).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSizePercentage(// default
    13).defaultDisplayImageOptions(// default
    options).build();
    ImageLoader.getInstance().init(config);
}
Also used : FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Aggregations

ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)65 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)36 File (java.io.File)23 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)18 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)16 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)14 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)12 BaseImageDownloader (com.nostra13.universalimageloader.core.download.BaseImageDownloader)12 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)10 View (android.view.View)7 TextView (android.widget.TextView)7 UnlimitedDiscCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache)7 Bitmap (android.graphics.Bitmap)6 ImageView (android.widget.ImageView)6 WeakMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache)6 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)6 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)6 ImageLoader (com.nostra13.universalimageloader.core.ImageLoader)5 IOException (java.io.IOException)5 ListView (android.widget.ListView)4