Search in sources :

Example 21 with ImageLoaderConfiguration

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);
}
Also used : ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 22 with ImageLoaderConfiguration

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();
}
Also used : UnlimitedDiscCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache) Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) WeakMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 23 with ImageLoaderConfiguration

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);
}
Also used : TotalSizeLimitedDiscCache(com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) URLConnectionImageDownloader(com.nostra13.universalimageloader.core.download.URLConnectionImageDownloader) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 24 with ImageLoaderConfiguration

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);
}
Also used : NonViewAware(com.nostra13.universalimageloader.core.imageaware.NonViewAware)

Example 25 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)

Aggregations

ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)33 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)16 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)12 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)10 File (java.io.File)8 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)6 UnlimitedDiscCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache)4 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)4 BaseImageDownloader (com.nostra13.universalimageloader.core.download.BaseImageDownloader)4 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)3 Intent (android.content.Intent)2 ImageLoader (com.nostra13.universalimageloader.core.ImageLoader)2 BaseImageDecoder (com.nostra13.universalimageloader.core.decode.BaseImageDecoder)2 SimpleBitmapDisplayer (com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer)2 SharedPreferences (android.content.SharedPreferences)1 Handler (android.os.Handler)1 ActionBar (android.support.v7.app.ActionBar)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1 View (android.view.View)1 ListView (android.widget.ListView)1