Search in sources :

Example 1 with DiskCache

use of com.nostra13.universalimageloader.cache.disc.DiskCache in project Slide by ccrama.

the class ImageLoaderUnescape method initImageLoader.

public static void initImageLoader(Context context) {
    long discCacheSize = 1024 * 1024;
    DiskCache discCache;
    File dir = getCacheDirectory(context);
    int threadPoolSize;
    discCacheSize *= 100;
    threadPoolSize = 7;
    if (discCacheSize > 0) {
        try {
            dir.mkdir();
            discCache = new LruDiskCache(dir, new Md5FileNameGenerator(), discCacheSize);
        } catch (IOException e) {
            discCache = new UnlimitedDiskCache(dir);
        }
    } else {
        discCache = new UnlimitedDiskCache(dir);
    }
    options = new DisplayImageOptions.Builder().cacheOnDisk(true).bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2).cacheInMemory(false).resetViewBeforeLoading(false).displayer(new FadeInBitmapDisplayer(250)).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(threadPoolSize).denyCacheImageMultipleSizesInMemory().diskCache(discCache).threadPoolSize(4).imageDownloader(new OkHttpImageDownloader(context)).defaultDisplayImageOptions(options).build();
    if (ImageLoader.getInstance().isInited()) {
        ImageLoader.getInstance().destroy();
    }
    imageLoader = ImageLoaderUnescape.getInstance();
    imageLoader.init(config);
}
Also used : Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) IOException(java.io.IOException) DiskCache(com.nostra13.universalimageloader.cache.disc.DiskCache) UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) LruDiskCache(com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache) UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) OkHttpImageDownloader(me.ccrama.redditslide.util.OkHttpImageDownloader) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) LruDiskCache(com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 2 with DiskCache

use of com.nostra13.universalimageloader.cache.disc.DiskCache in project BaseProject by fly803.

the class AppApplication method initImageLoader.

private void initImageLoader() {
    // 初始化 Image-Loader
    DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).build();
    ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this).memoryCache(new LruMemoryCache(MEMORY_SIZE)).diskCache(new UnlimitedDiscCache(new File(getCacheDir(), "caches"))).diskCacheSize(DISK_SIZE).defaultDisplayImageOptions(options).build();
    ImageLoader.getInstance().init(configuration);
}
Also used : UnlimitedDiscCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) File(java.io.File) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 3 with DiskCache

use of com.nostra13.universalimageloader.cache.disc.DiskCache in project Android-Universal-Image-Loader by nostra13.

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 4 with DiskCache

use of com.nostra13.universalimageloader.cache.disc.DiskCache in project MGit by maks.

the class SheimiFragmentActivity method setupImageLoader.

private void setupImageLoader() {
    DisplayImageOptions mDisplayOptions = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageForEmptyUri(R.drawable.ic_default_author).showImageOnFail(R.drawable.ic_default_author).build();
    File cacheDir = StorageUtils.getCacheDirectory(this);
    ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this).defaultDisplayImageOptions(mDisplayOptions).diskCache(new UnlimitedDiskCache(cacheDir)).diskCacheSize(SIZE).imageDownloader(new AvatarDownloader(this)).build();
    mImageLoader = ImageLoader.getInstance();
    mImageLoader.init(configuration);
}
Also used : UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) AvatarDownloader(me.sheimi.android.avatar.AvatarDownloader) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 5 with DiskCache

use of com.nostra13.universalimageloader.cache.disc.DiskCache in project BlogSource by TeachCourse.

the class App method config.

/**
 * 初始化ImageLoader配置
 *
 * @param context
 */
private ImageLoaderConfiguration config(Context context) {
    File cacheDir = StorageUtils.getOwnCacheDirectory(context, CACHE);
    if (!cacheDir.exists()) {
        cacheDir.mkdirs();
    }
    ImageLoaderConfiguration options = new ImageLoaderConfiguration.Builder(context).memoryCacheExtraOptions(480, 800).denyCacheImageMultipleSizesInMemory().tasksProcessingOrder(QueueProcessingType.LIFO).diskCache(new UnlimitedDiskCache(cacheDir)).build();
    return options;
}
Also used : UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

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