Search in sources :

Example 41 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 42 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project PLDroidPlayer by pili-engineering.

the class MainActivity method initImageLoader.

private void initImageLoader() {
    // sdcard目录
    File cacheDir = StorageUtils.getOwnCacheDirectory(this, DEFAULT_CACHE_DIR_NAME);
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).diskCache(// default 可以自定义缓存路径
    new UnlimitedDiskCache(cacheDir)).diskCacheSize(50 * 1024 * 1024).diskCacheFileCount(100).memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024).memoryCacheSizePercentage(13).build();
    ImageLoader.getInstance().init(config);
}
Also used : UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 43 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project ZhihuDailyPurify by izzyleung.

the class ZhihuDailyPurifyApplication method initImageLoader.

public static void initImageLoader(Context context) {
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).denyCacheImageMultipleSizesInMemory().threadPriority(Thread.NORM_PRIORITY - 2).diskCacheFileNameGenerator(new Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO).build();
    ImageLoader.getInstance().init(config);
}
Also used : Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 44 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project PhotoNoter by yydcdut.

the class GalleryApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    if (BuildConfig.LOG_DEBUG) {
        LeakCanary.install(this);
    }
    YLog.setDEBUG(BuildConfig.LOG_DEBUG);
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).threadPriority(Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory().discCacheFileNameGenerator(new Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO).build();
    ImageLoader.getInstance().init(config);
    DisplayImageOptions sOptions = new DisplayImageOptions.Builder().cacheInMemory(//设置下载的图片是否缓存在内存中
    true).considerExifParams(//是否考虑JPEG图像EXIF参数(旋转,翻转)
    true).bitmapConfig(//设置图片的解码类型//
    Bitmap.Config.RGB_565).build();
    //构建完成
    PGEditImageLoader.initImageLoader(this);
    PGEditSDK.instance().initSDK(this);
}
Also used : Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 45 with ImageLoaderConfiguration

use of com.nostra13.universalimageloader.core.ImageLoaderConfiguration in project UltimateAndroid by cymcsg.

the class CommonApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    ImageLoaderConfiguration config = UniversalImageLoader.getDefaultImageLoaderConfiguration(getApplicationContext());
    ImageLoader.getInstance().init(config);
    //  ActiveAndroid.initialize(this);
    AppLockManager.getInstance().enableDefaultAppLockIfAvailable(this);
//  CalligraphyConfig.initDefault("fonts/Satisfy-Regular.ttf", R.attr.fontPath);
}
Also used : ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Aggregations

ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)65 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)36 File (java.io.File)23 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)18 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)16 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)14 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)12 BaseImageDownloader (com.nostra13.universalimageloader.core.download.BaseImageDownloader)12 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)10 View (android.view.View)7 TextView (android.widget.TextView)7 UnlimitedDiscCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache)7 Bitmap (android.graphics.Bitmap)6 ImageView (android.widget.ImageView)6 WeakMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache)6 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)6 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)6 ImageLoader (com.nostra13.universalimageloader.core.ImageLoader)5 IOException (java.io.IOException)5 ListView (android.widget.ListView)4