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);
}
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;
}
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);
}
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);
}
Aggregations