Search in sources :

Example 6 with DiskCache

use of com.nostra13.universalimageloader.cache.disc.DiskCache in project LibreraReader by foobnix.

the class IMG method init.

public static void init(Context context) {
    IMG.context = context;
    bookBGWithMark = context.getResources().getDrawable(R.drawable.bookeffect2);
    bookBGNoMark = context.getResources().getDrawable(R.drawable.bookeffect1);
    final Builder builder = new DisplayImageOptions.Builder();
    builder.cacheInMemory(true);
    builder.cacheOnDisk(true);
    builder.showImageOnLoading(COLOR_DRAWABLE);
    builder.showImageOnFail(COLOR_DRAWABLE);
    builder.showImageForEmptyUri(COLOR_DRAWABLE);
    builder.bitmapConfig(BMP_CFG);
    builder.imageScaleType(ImageScaleType.NONE);
    builder.resetViewBeforeLoading(RESET_VIEW_BEFORE_LOADING);
    builder.considerExifParams(false);
    builder.decodingOptions(new Options());
    final ImageLoaderConfiguration config = // 
    new ImageLoaderConfiguration.Builder(context).threadPoolSize(// 
    1).threadPriority(// 
    Thread.NORM_PRIORITY).defaultDisplayImageOptions(// 
    builder.build()).diskCache(// 
    new UnlimitedDiskCache(new File(context.getExternalCacheDir(), "Images-1"))).imageDownloader(// 
    ImageExtractor.getInstance(context)).build();
    ImageLoader.getInstance().init(config);
}
Also used : DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) Options(android.graphics.BitmapFactory.Options) UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) Builder(com.nostra13.universalimageloader.core.DisplayImageOptions.Builder) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) File(java.io.File)

Example 7 with DiskCache

use of com.nostra13.universalimageloader.cache.disc.DiskCache in project LibreraReader by foobnix.

the class DefaultConfigurationFactory method createDiskCache.

/**
 * Creates default implementation of {@link DiskCache} depends on incoming parameters
 */
public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator, long diskCacheSize, int diskCacheFileCount) {
    File reserveCacheDir = createReserveDiskCacheDir(context);
    if (diskCacheSize > 0 || diskCacheFileCount > 0) {
        File individualCacheDir = StorageUtils.getIndividualCacheDirectory(context);
        try {
            return new LruDiskCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize, diskCacheFileCount);
        } catch (IOException e) {
            L.e(e);
        // continue and create unlimited cache
        }
    }
    File cacheDir = StorageUtils.getCacheDirectory(context);
    return new UnlimitedDiskCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
}
Also used : UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) LruDiskCache(com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache) IOException(java.io.IOException) File(java.io.File)

Example 8 with DiskCache

use of com.nostra13.universalimageloader.cache.disc.DiskCache in project QuickAndroid by ImKarl.

the class QAImageLoaderConfig method getConfig.

/**
 * 获取加载配置
 * @param context
 * @param imageOnLoading 加载中显示的图片
 * @param imageOnFail 加载失败显示的图片
 * @return
 */
public static ImageLoaderConfiguration getConfig(Context context, Drawable imageOnLoading, Drawable imageOnFail) {
    DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(// 加载中
    imageOnLoading).showImageForEmptyUri(// 图片Uri为空或是错误的时候显示的图片
    imageOnFail).showImageOnFail(// resource or drawable
    imageOnFail).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 9 with DiskCache

use of com.nostra13.universalimageloader.cache.disc.DiskCache in project KenBurnsView by flavioarfaria.

the class FromURLActivity method loadImage.

private void loadImage() {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        String cacheDirName = "." + getString(R.string.app_name);
        cacheDir = new File(Environment.getExternalStorageDirectory(), cacheDirName);
    } else {
        cacheDir = getCacheDir();
    }
    if (!cacheDir.exists()) {
        cacheDir.mkdirs();
    }
    config = new ImageLoaderConfiguration.Builder(this).memoryCache(new WeakMemoryCache()).denyCacheImageMultipleSizesInMemory().diskCache(new UnlimitedDiscCache(cacheDir)).threadPoolSize(5).build();
    options = new DisplayImageOptions.Builder().bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.IN_SAMPLE_INT).cacheOnDisk(true).cacheInMemory(true).build();
    imageLoader.init(config);
    imageLoader.displayImage("http://i.imgur.com/gysR4Ee.jpg", mImg, options, this);
}
Also used : UnlimitedDiscCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache) WeakMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache) File(java.io.File)

Example 10 with DiskCache

use of com.nostra13.universalimageloader.cache.disc.DiskCache in project GomoTest by suReZj.

the class BaseActivity method initImageLoader.

/**
 * 初始化图片载入框架
 */
private void initImageLoader() {
    File cacheDir = StorageUtils.getCacheDirectory(this);
    int MAXMEMONRY = (int) (Runtime.getRuntime().maxMemory());
    // System.out.println("dsa-->"+MAXMEMONRY+"   "+(MAXMEMONRY/5));//.memoryCache(new
    // LruMemoryCache(50 * 1024 * 1024))
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).memoryCacheExtraOptions(480, 800).defaultDisplayImageOptions(defaultOptions).diskCacheExtraOptions(480, 800, null).threadPoolSize(3).threadPriority(Thread.NORM_PRIORITY - 2).tasksProcessingOrder(QueueProcessingType.FIFO).denyCacheImageMultipleSizesInMemory().memoryCache(new LruMemoryCache(MAXMEMONRY / 5)).diskCache(new UnlimitedDiskCache(cacheDir)).diskCacheFileNameGenerator(// default
    new HashCodeFileNameGenerator()).imageDownloader(// default
    new BaseImageDownloader(this)).imageDecoder(// default
    new BaseImageDecoder(false)).defaultDisplayImageOptions(DisplayImageOptions.createSimple()).build();
    ImageLoader.getInstance().init(config);
}
Also used : UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) HashCodeFileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator) 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)

Aggregations

File (java.io.File)18 ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)16 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)15 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)9 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)8 LruDiskCache (com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache)5 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)5 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)5 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)5 BaseImageDownloader (com.nostra13.universalimageloader.core.download.BaseImageDownloader)5 IOException (java.io.IOException)5 DiskCache (com.nostra13.universalimageloader.cache.disc.DiskCache)3 UnlimitedDiscCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache)3 BaseImageDecoder (com.nostra13.universalimageloader.core.decode.BaseImageDecoder)3 WeakMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache)2 OkHttpImageDownloader (me.ccrama.redditslide.util.OkHttpImageDownloader)2 Options (android.graphics.BitmapFactory.Options)1 IInnerImageSetter (com.example.test.andlang.util.imageload.IInnerImageSetter)1 LimitedAgeDiskCache (com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiskCache)1 Builder (com.nostra13.universalimageloader.core.DisplayImageOptions.Builder)1