use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project ListenerMusicPlayer by hefuyicoder.
the class ListenerApp method initImageLoader.
private void initImageLoader() {
ImageLoaderConfiguration localImageLoaderConfiguration = new ImageLoaderConfiguration.Builder(this).build();
ImageLoader.getInstance().init(localImageLoaderConfiguration);
}
use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project SimplifyReader by chentao0707.
the class ImageLoaderHelper method getImageLoaderConfiguration.
public ImageLoaderConfiguration getImageLoaderConfiguration(String filePath) {
File cacheDir = null;
if (!CommonUtils.isEmpty(filePath)) {
cacheDir = StorageUtils.getOwnCacheDirectory(mContext, filePath);
} else {
cacheDir = StorageUtils.getCacheDirectory(mContext);
}
ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(mContext);
builder.denyCacheImageMultipleSizesInMemory();
builder.diskCacheSize(512 * 1024 * 1024);
builder.diskCacheExtraOptions(720, 1280, null);
builder.diskCache(new UnlimitedDiscCache(cacheDir));
builder.diskCacheFileNameGenerator(new Md5FileNameGenerator());
builder.memoryCacheSizePercentage(14);
builder.memoryCacheSize(2 * 1024 * 1024);
builder.memoryCacheExtraOptions(720, 1280);
builder.memoryCache(new WeakMemoryCache());
builder.threadPoolSize(3);
builder.threadPriority(Thread.NORM_PRIORITY - 2);
builder.defaultDisplayImageOptions(getDisplayOptions());
return builder.build();
}
use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project android-ui-design-pattern by MathieuCalba.
the class UIDesignPatternApplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
final DisplayImageOptions defaultDisplayImageOptions = //
new DisplayImageOptions.Builder().cacheInMemory().cacheOnDisc().displayer(//
new FadeInBitmapDisplayer(250)).showImageForEmptyUri(//
R.drawable.ic_launcher).showStubImage(//
R.drawable.ic_launcher).build();
final File cacheDir = StorageUtils.getOwnCacheDirectory(getApplicationContext(), "YANA/ImageCache");
final ImageLoaderConfiguration config = //
new ImageLoaderConfiguration.Builder(getApplicationContext()).defaultDisplayImageOptions(//
defaultDisplayImageOptions).discCache(//
new TotalSizeLimitedDiscCache(cacheDir, new Md5FileNameGenerator(), 10 * 1024 * 1024)).imageDownloader(//
new URLConnectionImageDownloader()).memoryCacheSize(// 2 Mb
2 * 1024 * 1024).tasksProcessingOrder(//
QueueProcessingType.LIFO).threadPoolSize(//
3).threadPriority(//
Thread.NORM_PRIORITY - 2).build();
ImageLoader.getInstance().init(config);
}
use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project Android-Universal-Image-Loader by nostra13.
the class ImageLoader method loadImage.
/**
* Adds load image task to execution pool. Image will be returned with
* {@link ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)} callback}.
* <br />
* <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method call
*
* @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
* @param targetImageSize Minimal size for {@link Bitmap} which will be returned in
* {@linkplain ImageLoadingListener#onLoadingComplete(String, android.view.View,
* android.graphics.Bitmap)} callback}. Downloaded image will be decoded
* and scaled to {@link Bitmap} of the size which is <b>equal or larger</b> (usually a bit
* larger) than incoming targetImageSize.
* @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
* decoding and displaying. If <b>null</b> - default display image options
* {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
* from configuration} will be used.<br />
* @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires
* events on UI thread if this method is called on UI thread.
* @param progressListener {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener
* Listener} for image loading progress. Listener fires events on UI thread if this method
* is called on UI thread. Caching on disk should be enabled in
* {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions options} to make
* this listener work.
* @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
*/
public void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options, ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
checkConfiguration();
if (targetImageSize == null) {
targetImageSize = configuration.getMaxImageSize();
}
if (options == null) {
options = configuration.defaultDisplayImageOptions;
}
NonViewAware imageAware = new NonViewAware(uri, targetImageSize, ViewScaleType.CROP);
displayImage(uri, imageAware, options, listener, progressListener);
}
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);
}
Aggregations