Search in sources :

Example 51 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project howabout-android by recomio.

the class HowaboutApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    // initialze universal image loader.
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheInMemory().cacheOnDisc().build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).defaultDisplayImageOptions(defaultOptions).build();
    ImageLoader.getInstance().init(config);
    // saved playlist.
    String prefsName = getString(R.string.prefs_name);
    SharedPreferences prefs = getSharedPreferences(prefsName, 0);
    String trackListJson = prefs.getString("trackListJson", null);
    // initialize playlistAdapter to use globally.
    if (trackListJson == null) {
        playlistAdapter = new MusicPlaylistAdapter(this);
    } else {
        Gson gson = new Gson();
        TrackList trackList = gson.fromJson(trackListJson, TrackList.class);
        playlistAdapter = new MusicPlaylistAdapter(this, trackList);
    }
    MusicPlayerService.setPlaylistAdapter(playlistAdapter);
}
Also used : SharedPreferences(android.content.SharedPreferences) MusicPlaylistAdapter(io.recom.howabout.category.music.adapter.MusicPlaylistAdapter) TrackList(io.recom.howabout.category.music.model.TrackList) Gson(com.google.gson.Gson) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 52 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project Slide by ccrama.

the class ImageFlairs method initFlairImageLoader.

public static FlairImageLoader initFlairImageLoader(Context context) {
    // 100 MB limit
    long discCacheSize = 1024 * 1024 * 100;
    DiskCache discCache;
    File dir = getCacheDirectory(context);
    discCacheSize *= 100;
    int 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).imageScaleType(ImageScaleType.NONE).cacheInMemory(false).resetViewBeforeLoading(false).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(threadPoolSize).denyCacheImageMultipleSizesInMemory().diskCache(discCache).threadPoolSize(4).imageDownloader(new OkHttpImageDownloader(context)).defaultDisplayImageOptions(options).build();
    if (FlairImageLoader.getInstance().isInited()) {
        FlairImageLoader.getInstance().destroy();
    }
    imageLoader = FlairImageLoader.getInstance();
    imageLoader.init(config);
    return imageLoader;
}
Also used : UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) OkHttpImageDownloader(me.ccrama.redditslide.util.OkHttpImageDownloader) Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) LruDiskCache(com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache) IOException(java.io.IOException) UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) DiskCache(com.nostra13.universalimageloader.cache.disc.DiskCache) LruDiskCache(com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 53 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project Slide by ccrama.

the class ImageLoaderUtils method initImageLoader.

public static void initImageLoader(Context context) {
    long discCacheSize = 1024 * 1024;
    DiskCache discCache;
    File dir = getCacheDirectory(context);
    discCacheSize *= 100;
    int 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(SettingValues.highColorspaceImages ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565).imageScaleType(SettingValues.highColorspaceImages ? ImageScaleType.NONE_SAFE : ImageScaleType.IN_SAMPLE_POWER_OF_2).cacheInMemory(false).resetViewBeforeLoading(false).displayer(new FadeInBitmapDisplayer(250)).build();
    if (SettingValues.highColorspaceImages) {
        SubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.ARGB_8888);
    }
    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) 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 54 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration 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)

Aggregations

ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)52 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)25 File (java.io.File)21 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)18 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)14 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)13 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)10 BaseImageDownloader (com.nostra13.universalimageloader.core.download.BaseImageDownloader)10 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)9 UnlimitedDiscCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache)6 WeakMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache)4 ImageLoader (com.nostra13.universalimageloader.core.ImageLoader)4 IOException (java.io.IOException)4 DiskCache (com.nostra13.universalimageloader.cache.disc.DiskCache)3 LruDiskCache (com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache)3 BaseImageDecoder (com.nostra13.universalimageloader.core.decode.BaseImageDecoder)3 Intent (android.content.Intent)2 Handler (android.os.Handler)2 SimpleBitmapDisplayer (com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer)2 NonViewAware (com.nostra13.universalimageloader.core.imageaware.NonViewAware)2