Java Code Examples for com.nostra13.universalimageloader.core.ImageLoader#init()

The following examples show how to use com.nostra13.universalimageloader.core.ImageLoader#init() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageLoaderTools.java    From Social with Apache License 2.0 6 votes vote down vote up
private static ImageLoader initImageLoader(Context context) {
	DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
       .cacheInMemory(true)
       .cacheOnDisc(true)
       .showStubImage(R.drawable.image_holder)
       .showImageForEmptyUri(R.drawable.image_holder)
       .showImageOnFail(R.drawable.image_holder)
       .build();
	
	ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
	.defaultDisplayImageOptions(defaultOptions)//
	.discCacheSize(DISK_CACHE_SIZE_BYTES)
	.memoryCacheSize(MEMORY_CACHE_SIZE_BYTES)
	.build();
	
	ImageLoader tmpIL = ImageLoader.getInstance();
	tmpIL.init(config);
	return tmpIL;
	
}
 
Example 2
Source File: ImageLoaderTools.java    From Social with Apache License 2.0 6 votes vote down vote up
private static ImageLoader initImageLoader(Context context) {
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisc(true)
            .showStubImage(R.drawable.image_holder)
            .showImageForEmptyUri(R.drawable.image_holder)
            .showImageOnFail(R.drawable.image_holder)
            .build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .defaultDisplayImageOptions(defaultOptions)//
            .discCacheSize(DISK_CACHE_SIZE_BYTES)
            .memoryCacheSize(MEMORY_CACHE_SIZE_BYTES)
            .build();

    ImageLoader tmpIL = ImageLoader.getInstance();
    tmpIL.init(config);
    return tmpIL;

}
 
Example 3
Source File: ShoppingCartActivity.java    From ShoppingCartActivity with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_shopping_cart_activity);
    initView();
    ImageLoader imageLoader=ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(this));
}
 
Example 4
Source File: ImageUtils.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
     * 初始化 ImageLoader
     *
     * @param context
     */
    public static ImageLoader initImageLoader(Context context) {

        DisplayImageOptions options = getDefaultDisplayImageOptions();

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                context.getApplicationContext())
                .threadPoolSize(10)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .tasksProcessingOrder(QueueProcessingType.FIFO)
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new UsingFreqLimitedMemoryCache(3 * 1024 * 1024))
                .discCache(new UnlimitedDiskCache(getDefaultCacheDir()))
                .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
                .imageDownloader(
                        new BaseImageDownloader(context.getApplicationContext()))
                .defaultDisplayImageOptions(options)
//                .writeDebugLogs()
                .build();


        ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.init(config);

        return imageLoader;

    }
 
Example 5
Source File: ImageUtils.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
     * 初始化 ImageLoader
     *
     * @param context
     */
    public static ImageLoader initNoCacheImageLoader(Context context) {



        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .resetViewBeforeLoading(false).delayBeforeLoading(100)
                .considerExifParams(false)
                .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .displayer(new SimpleBitmapDisplayer()).handler(new Handler())
                .cacheInMemory(false).cacheOnDisk(false)
//                .showImageForEmptyUri(R.drawable.default_pic)
//                .showImageOnFail(R.drawable.default_pic)
                .build();


        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                context.getApplicationContext())
                .threadPoolSize(10)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .tasksProcessingOrder(QueueProcessingType.FIFO)
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new UsingFreqLimitedMemoryCache(3 * 1024 * 1024))
                .imageDownloader(
                        new BaseImageDownloader(context.getApplicationContext()))
                .defaultDisplayImageOptions(options)
//                .writeDebugLogs()
                .build();


        ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.init(config);

        return imageLoader;

    }
 
Example 6
Source File: ImageBaseUtils.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
     * 初始化 ImageLoader
     *
     * @param context
     */
    public static ImageLoader initImageLoader(Context context) {

        DisplayImageOptions options = getDefaultDisplayImageOptions();

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                context.getApplicationContext())
                .threadPoolSize(10)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .tasksProcessingOrder(QueueProcessingType.FIFO)
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new UsingFreqLimitedMemoryCache(3 * 1024 * 1024))
                .discCache(new UnlimitedDiskCache(getDefaultImageCacheDir()))
                .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
                .imageDownloader(
                        new BaseImageDownloader(context.getApplicationContext()))
                .defaultDisplayImageOptions(options)
//                .writeDebugLogs()
                .build();


        ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.init(config);

        return imageLoader;

    }
 
Example 7
Source File: ImageLibUitls.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
     * 初始化 ImageLoader
     *
     * @param context
     */
    public static ImageLoader initImageLoader(Context context, File cacheDir, Drawable drawableEmpty, Drawable drawableFail) {

        DisplayImageOptions options = getDisplayImageOptions(drawableEmpty, drawableFail);


        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                context.getApplicationContext())
                .threadPoolSize(10)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .tasksProcessingOrder(QueueProcessingType.FIFO)
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new UsingFreqLimitedMemoryCache(3 * 1024 * 1024))
                .discCache(new UnlimitedDiskCache(cacheDir))
                .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
                .imageDownloader(
                        new BaseImageDownloader(context.getApplicationContext()))
                .defaultDisplayImageOptions(options)
//                .writeDebugLogs()
                .build();


        ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.init(config);

        return imageLoader;

    }
 
Example 8
Source File: Global.java    From PinchImageView with MIT License 5 votes vote down vote up
public static ImageLoader getImageLoader(Context context) {
    ImageLoader imageLoader = ImageLoader.getInstance();
    if (!imageLoader.isInited()) {
        imageLoader.init(ImageLoaderConfiguration.createDefault(context));
    }
    return imageLoader;
}