com.nostra13.universalimageloader.core.ImageLoaderConfiguration Java Examples

The following examples show how to use com.nostra13.universalimageloader.core.ImageLoaderConfiguration. 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: ChhApplication.java    From ChipHellClient with Apache License 2.0 6 votes vote down vote up
private void initImageLoader() {
    DisplayImageOptions defaultDisplayImageOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .showImageForEmptyUri(R.drawable.logo)
            .showImageOnFail(R.drawable.logo)
            .showImageOnLoading(R.drawable.logo)
            // .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
            .build();

    OkHttpClient client = new OkHttpClient.Builder()
            .connectTimeout(10, TimeUnit.SECONDS)
            .readTimeout(40, TimeUnit.SECONDS)
            .cookieJar(new JavaNetCookieJar(WebViewCookieHandler.getInstance()))
            .build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
            .denyCacheImageMultipleSizesInMemory()
            .defaultDisplayImageOptions(defaultDisplayImageOptions)
            .imageDownloader(new OkHttpImageDownloader(this, client))
            .build();
    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config);

}
 
Example #2
Source File: ImageHelper.java    From buddycloud-android with Apache License 2.0 6 votes vote down vote up
public static void configUIL(Context context) {
	File cacheDir = new File(context.getExternalCacheDir(), UIL_CACHE);
	
	DisplayImageOptions defaultOptions = defaultImageOptions();
	
	HttpClientImageDownloader downloader = new HttpClientImageDownloader(context, 
			BuddycloudHTTPHelper.createHttpClient(context));
	
	ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
			.discCache(new TotalSizeLimitedDiscCache(cacheDir, 50 * 1024 * 1024))
			.imageDownloader(downloader)
			.defaultDisplayImageOptions(defaultOptions)
			.writeDebugLogs()
			.build();
	
	ImageLoader.getInstance().init(config);
}
 
Example #3
Source File: MainActivity.java    From XKik with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main); // main activity
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // toolbar
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    getSupportFragmentManager().beginTransaction().replace(R.id.contentframe, new main_fragment()).commit();

    Settings.verifyStoragePermissions(this); // make sure we can access settings


    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
            .build();
    ImageLoader.getInstance().init(config);
}
 
Example #4
Source File: MyApplication.java    From GithubTrends with Apache License 2.0 6 votes vote down vote up
public void initImageLoader(Context context) {
    // This configuration tuning is custom. You can tune every option, you may tune some of them,
    // or you can create default configuration by
    //  ImageLoaderConfiguration.createDefault(this);
    // method.
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .memoryCacheSizePercentage(25)
            .diskCacheFileNameGenerator(new Md5FileNameGenerator())
            .diskCacheSize(100 * 1024 * 1024)
            .tasksProcessingOrder(QueueProcessingType.LIFO)
            .writeDebugLogs() // Remove for release app
            .build();
    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config);
}
 
Example #5
Source File: ImageLoaderManager.java    From Focus with GNU General Public License v3.0 6 votes vote down vote up
public static void init(Context context) {

        ColorDrawable defaultDrawable = new ColorDrawable(context.getResources().getColor(R.color.main_grey_light));

        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(defaultDrawable)
                .showImageForEmptyUri(defaultDrawable)
                .showImageOnFail(defaultDrawable)
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .build();

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .defaultDisplayImageOptions(options)
                .memoryCache(new LruMemoryCache(8 * 1024 * 1024))
                .diskCacheSize(100 * 1024 * 1024)
                .diskCacheFileCount(100)
                .writeDebugLogs()
                .build();

        ImageLoader.getInstance().init(config);
    }
 
Example #6
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 #7
Source File: MainApplication.java    From snowdream-books-android with Apache License 2.0 6 votes vote down vote up
private void initImageLoader(){
        Context context = getApplicationContext();
        File cacheDir = StorageUtils.getCacheDirectory(context);
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
                .diskCacheExtraOptions(480, 800, null)
                .threadPriority(Thread.NORM_PRIORITY - 2) // default
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
                .memoryCacheSize(2 * 1024 * 1024)
                .memoryCacheSizePercentage(13) // default
                .diskCache(new UnlimitedDiscCache(cacheDir)) // default
                .diskCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(100)
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .imageDecoder(new BaseImageDecoder(false)) // default
                .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
//                .writeDebugLogs()
                .build();

        ImageLoader.getInstance().init(config);
    }
 
Example #8
Source File: GankCommonAdapter.java    From Gank with Apache License 2.0 6 votes vote down vote up
public GankCommonAdapter(@NonNull Context context, List<CommonDate.ResultsEntity> datas) {
    super(context, datas, R.layout.item_common);
    //创建默认的ImageLoader配置参数
    ImageLoaderConfiguration configuration = ImageLoaderConfiguration.createDefault(context);
    ImageLoader.getInstance().init(configuration); // Get singleton instance

    push_left_in = AnimationUtils.loadAnimation(context, R.anim.push_left_in);
    push_right_in = AnimationUtils.loadAnimation(context, R.anim.push_right_in);
    push_left_in.setDuration(1000);
    push_right_in.setDuration(1000);

    //显示图片的配置
    options = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();
}
 
Example #9
Source File: UILKit.java    From XRichText with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化
 *
 * @param context
 */
private UILKit(Context context) {
    File cacheDir = getDiskCacheDir(context, "img");

    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .memoryCacheSize(10 * 1024 * 1024)
            .diskCache(new UnlimitedDiskCache(cacheDir))
            .diskCacheFileNameGenerator(new Md5FileNameGenerator())
            .diskCacheSize(50 * 1024 * 1024) // 50 MiB
            .tasksProcessingOrder(QueueProcessingType.LIFO);

    ImageLoader.getInstance().init(config.build());



    picOptions = new DisplayImageOptions.Builder()
            .imageScaleType(ImageScaleType.EXACTLY)
            .cacheOnDisk(false).cacheInMemory(false)
            .resetViewBeforeLoading(true)
            .displayer(new FadeInBitmapDisplayer(500)).build();
}
 
Example #10
Source File: ImageLoaderDemo.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_integration);
	PhotoView photoView = (PhotoView) findViewById(R.id.photoview);

	ImageLoader.getInstance().init(
			ImageLoaderConfiguration.createDefault(this));

	/**
	 * The Image URL is comes from my space. If it is invalid, you can
	 * change to any other picture url.
	 */
	ImageLoader.getInstance().displayImage(
			"http://dk-exp.qiniudn.com/saya.jpg", photoView);
}
 
Example #11
Source File: Application.java    From v2ex-daily-android with Apache License 2.0 6 votes vote down vote up
private void initiImageLoader() {
    DisplayImageOptions options = new DisplayImageOptions.Builder()
            .bitmapConfig(Bitmap.Config.RGB_565)
            .imageScaleType(ImageScaleType.EXACTLY)
            .cacheOnDisc(true)
            .displayer(new FadeInBitmapDisplayer(200))
            .showImageOnLoading(R.drawable.ic_launcher)
            .build();

    File cacheDir;
    if(Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED){
        cacheDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
    }else{
        cacheDir = getCacheDir();
    }
    ImageLoaderConfiguration.Builder configBuilder = new ImageLoaderConfiguration.Builder(mContext)
            .threadPoolSize(2)
            .memoryCache(new WeakMemoryCache())
            .denyCacheImageMultipleSizesInMemory()
            .discCache(new UnlimitedDiscCache(cacheDir))
            .defaultDisplayImageOptions(options);
    if(BuildConfig.DEBUG){
        configBuilder.writeDebugLogs();
    }
    ImageLoader.getInstance().init(configBuilder.build());
}
 
Example #12
Source File: ImageLoadUtil.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
public static void configuration(Context context) {
    if (imageLoader == null) {
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .threadPriority(Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory()
                .discCacheSize(MAX_DISK_CACHE_FILE_SIZE)
                        // .discCacheFileCount(MAX_DISK_CACHE_FILE_COUNT)
                .discCacheFileNameGenerator(new Md5FileNameGenerator())
                .tasksProcessingOrder(QueueProcessingType.LIFO)
                        // .writeDebugLogs() // 输入日志,打包发布的时候注释掉
                .build();

        ImageLoader.getInstance().init(config);

        imageLoader = ImageLoader.getInstance();
    }
}
 
Example #13
Source File: MainApplication.java    From android-imageviewer with Apache License 2.0 6 votes vote down vote up
public static void initImageLoader(Context context) {
    File cacheDir = StorageUtils.getCacheDirectory(context);
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
            .denyCacheImageMultipleSizesInMemory()
            .discCacheExtraOptions(480, 800, Bitmap.CompressFormat.JPEG, 75, null)
            .threadPriority(Thread.NORM_PRIORITY - 2) // default
            .tasksProcessingOrder(QueueProcessingType.FIFO) // default
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024)
            .memoryCacheSizePercentage(13) // default
            .discCache(new UnlimitedDiscCache(cacheDir)) // default
            .discCacheSize(50 * 1024 * 1024)
            .discCacheFileCount(100)
            .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
            .imageDownloader(new BaseImageDownloader(context)) // default
            .imageDecoder(new BaseImageDecoder(true)) // default
            .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
            .writeDebugLogs()
            .build();

    ImageLoader.getInstance().init(config);
}
 
Example #14
Source File: EditorActivity.java    From RichEditText with Apache License 2.0 6 votes vote down vote up
public void initImageLoader(Context context) {
	// This configuration tuning is custom. You can tune every option, you
	// may tune some of them,
	// or you can create default configuration by
	// ImageLoaderConfiguration.createDefault(this);
	// method.
	ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(
			context);
	config.threadPriority(Thread.NORM_PRIORITY - 2);
	config.denyCacheImageMultipleSizesInMemory();
	config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
	config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
	config.tasksProcessingOrder(QueueProcessingType.LIFO);
	config.writeDebugLogs(); // Remove for release app

	// Initialize ImageLoader with configuration.
	ImageLoader.getInstance().init(config.build());
	
}
 
Example #15
Source File: CustomGalleryActivity.java    From MultipleImagePicker with Apache License 2.0 6 votes vote down vote up
private void initImageLoader() {
	try {
		String CACHE_DIR = Environment.getExternalStorageDirectory()
				.getAbsolutePath() + "/.temp_tmp";
		new File(CACHE_DIR).mkdirs();

		File cacheDir = StorageUtils.getOwnCacheDirectory(getBaseContext(),
				CACHE_DIR);

		DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
				.cacheOnDisc(true).imageScaleType(ImageScaleType.EXACTLY)
				.bitmapConfig(Bitmap.Config.RGB_565).build();
		ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(
				getBaseContext())
				.defaultDisplayImageOptions(defaultOptions)
				.discCache(new UnlimitedDiscCache(cacheDir))
				.memoryCache(new WeakMemoryCache());

		ImageLoaderConfiguration config = builder.build();
		imageLoader = ImageLoader.getInstance();
		imageLoader.init(config);

	} catch (Exception e) {

	}
}
 
Example #16
Source File: MainActivity.java    From MutiPhotoChoser with Mozilla Public License 2.0 6 votes vote down vote up
private void initImageLoader() {
    if (!ImageLoader.getInstance().isInited()) {
        DisplayImageOptions.Builder displayBuilder = new DisplayImageOptions.Builder();
        displayBuilder.cacheInMemory(true);
        displayBuilder.cacheOnDisk(true);
        displayBuilder.showImageOnLoading(com.ns.mutiphotochoser.R.drawable.default_photo);
        displayBuilder.showImageForEmptyUri(com.ns.mutiphotochoser.R.drawable.default_photo);
        displayBuilder.considerExifParams(true);
        displayBuilder.bitmapConfig(Bitmap.Config.RGB_565);
        displayBuilder.imageScaleType(ImageScaleType.EXACTLY);
        displayBuilder.displayer(new FadeInBitmapDisplayer(300));

        ImageLoaderConfiguration.Builder loaderBuilder = new ImageLoaderConfiguration.Builder(getApplication());
        loaderBuilder.defaultDisplayImageOptions(displayBuilder.build());
        loaderBuilder.memoryCacheSize(getMemoryCacheSize());

        try {
            File cacheDir = new File(getExternalCacheDir() + File.separator + CacheConstant.IMAGE_CACHE_DIRECTORY);
            loaderBuilder.diskCache(new LruDiscCache(cacheDir, DefaultConfigurationFactory.createFileNameGenerator(), 500 * 1024 * 1024));
        } catch (IOException e) {
            e.printStackTrace();
        }
        ImageLoader.getInstance().init(loaderBuilder.build());
    }

}
 
Example #17
Source File: FlowApplication.java    From flow-android with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Crashlytics.start(this);

    // Do init here
    FlowAsyncClient.init(getApplicationContext());
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisc(true)
            .displayer(new FadeInBitmapDisplayer(500))
            .build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
            .defaultDisplayImageOptions(defaultOptions)
            .build();
    ImageLoader.getInstance().init(config);

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    if (preferences != null) {
        mIsUserLoggedIn = preferences.getBoolean(IS_USER_LOGGED_IN_KEY, false);
    }

    getMixpanel();
}
 
Example #18
Source File: MyApplication.java    From WliveTV with Apache License 2.0 6 votes vote down vote up
public static void initImageLoader(Context context) {
        // This configuration tuning is custom. You can tune every option, you may tune some of them,
        // or you can create default configuration by
        //  ImageLoaderConfiguration.createDefault(this);
        // method.
        ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
        config.threadPriority(Thread.NORM_PRIORITY - 4);
//        config.memoryCache(new WeakMemoryCache());
        config.memoryCacheExtraOptions(480, 800);
        config.memoryCacheSize(2 * 1024 * 1024);
        config.denyCacheImageMultipleSizesInMemory();
        config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
        config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
        config.diskCacheExtraOptions(480, 800, null);
        config.tasksProcessingOrder(QueueProcessingType.LIFO);
//        config.writeDebugLogs(); // Remove for release app
        config.imageDownloader(new BaseImageDownloader(context, 5 * 1000, 10 * 1000));
        config.threadPoolSize(1);
        // Initialize ImageLoader with configuration.
        ImageLoader.getInstance().init(config.build());
    }
 
Example #19
Source File: UniversalImageLoader.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
     * Get default ImageLoaderConfiguration.Builder,and you can easily change the builder.
     * @param context
     * @return
     */
    public static ImageLoaderConfiguration.Builder getDefaultImageLoaderConfigurationBuilder(Context context) {
        File cacheDir = StorageUtils.getCacheDirectory(context);
        ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(context)
//                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
//                .discCacheExtraOptions(480, 800, Bitmap.CompressFormat.JPEG, 75, null)
                .threadPoolSize(3) // default
                .threadPriority(Thread.NORM_PRIORITY - 1) // default
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .denyCacheImageMultipleSizesInMemory()
//                .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
//                .memoryCacheSize(2 * 1024 * 1024)
                .memoryCacheSizePercentage(13) // default
                .diskCache(new UnlimitedDiskCache(cacheDir)) // default
//                .discCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(1000)
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .imageDecoder(new BaseImageDecoder(false)) // default
                        //   .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
                .defaultDisplayImageOptions(getDefaultImageOptions());
        return builder;
    }
 
Example #20
Source File: UniversalImageLoader.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
public static ImageLoaderConfiguration.Builder getDefaultImageLoaderConfigurationBuilder(Context context) {
        File cacheDir = StorageUtils.getCacheDirectory(context);
        ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(context)
//                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
//                .discCacheExtraOptions(480, 800, Bitmap.CompressFormat.JPEG, 75, null)
                .threadPoolSize(3) // default
                .threadPriority(Thread.NORM_PRIORITY - 1) // default
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .denyCacheImageMultipleSizesInMemory()
//                .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
//                .memoryCacheSize(2 * 1024 * 1024)
                .memoryCacheSizePercentage(13) // default
                .discCache(new UnlimitedDiscCache(cacheDir)) // default
//                .discCacheSize(50 * 1024 * 1024)
                .discCacheFileCount(1000)
                .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .imageDecoder(new BaseImageDecoder(false)) // default
                        //   .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
                .defaultDisplayImageOptions(getDefaultImageOptions());
        return builder;
    }
 
Example #21
Source File: BaseApplication.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
private void initUil() {
    File cacheDir = SdCacheTools.getOwnImageCacheDir(this);
    ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .diskCache(new UnlimitedDiskCache(cacheDir))
            .diskCacheSize(50 * 1024 * 1024)
            .diskCacheFileCount(100)
            .diskCacheFileNameGenerator(new Md5FileNameGenerator())
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024)
            .memoryCacheSizePercentage(13)
            .tasksProcessingOrder(QueueProcessingType.LIFO)
            .build();
    ImageLoader.getInstance().init(configuration);
}
 
Example #22
Source File: AndroidUniversalImageLoaderSampleApplication.java    From android-opensource-library-56 with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            getApplicationContext())
            .threadPoolSize(3)
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024)
            .discCache(
                    new UnlimitedDiscCache(StorageUtils
                            .getCacheDirectory(getApplicationContext())))
            .build();

    ImageLoader.getInstance().init(config);
}
 
Example #23
Source File: BaseApplication.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public static void initImageLoader(Context context) {
    // This configuration tuning is custom. You can tune every option, you may tune some of them, 
    // or you can create default configuration by
    //  ImageLoaderConfiguration.createDefault(this);
    // method.
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .discCacheFileNameGenerator(new Md5FileNameGenerator())
            .tasksProcessingOrder(QueueProcessingType.LIFO)
            .enableLogging() // Not necessary in common
            .build();
    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config);
}
 
Example #24
Source File: ImageLoaderUtils.java    From q-municate-android with Apache License 2.0 5 votes vote down vote up
public static ImageLoaderConfiguration getImageLoaderConfiguration(Context context) {
    final int MEMORY_CACHE_LIMIT = 2 * 1024 * 1024;
    final int THREAD_POOL_SIZE = 3;

    ImageLoaderConfiguration imageLoaderConfiguration = new ImageLoaderConfiguration.Builder(context)
            .threadPoolSize(THREAD_POOL_SIZE).threadPriority(Thread.NORM_PRIORITY)
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new UsingFreqLimitedMemoryCache(MEMORY_CACHE_LIMIT))
            .defaultDisplayImageOptions(ImageLoaderUtils.UIL_DEFAULT_DISPLAY_OPTIONS)
            .imageDecoder(new SmartUriDecoder(context, new BaseImageDecoder(false)))
            .denyCacheImageMultipleSizesInMemory()
            .discCacheFileNameGenerator(new HashCodeFileNameGeneratorWithoutToken()).build();
    return imageLoaderConfiguration;
}
 
Example #25
Source File: DemoApplication.java    From AspectJX-Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    LibrarySDK.init();

    ImageLoader.getInstance().init(new ImageLoaderConfiguration.Builder(this).build());

    ARouter.openLog();
    ARouter.openDebug();
    ARouter.init(this);
}
 
Example #26
Source File: SameLinkGridApter.java    From MarketAndroidApp with Apache License 2.0 5 votes vote down vote up
public SameLinkGridApter(Context context, List<CommodityModel> listItemRecommend) {
    this.context = context;
    this.listItemSameLink = listItemRecommend;
    inflater = LayoutInflater.from(context);

    //实例化ImageLoader
    ImageLoaderConfiguration configuration = ImageLoaderConfiguration.createDefault(context);
    ImageLoader.getInstance().init(configuration);
}
 
Example #27
Source File: DemoApplication.java    From JCVideoPlayer with MIT License 5 votes vote down vote up
private void initUniversalImageLoader() {
    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(getApplicationContext());
    config.threadPriority(Thread.NORM_PRIORITY - 2);
    config.denyCacheImageMultipleSizesInMemory();
    config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
    config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
    config.tasksProcessingOrder(QueueProcessingType.LIFO);
    config.writeDebugLogs(); // Remove for releaseAllVideos app
    config.defaultDisplayImageOptions(getDefaultDisplayImageOption());
    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config.build());
}
 
Example #28
Source File: Helper.java    From smartcoins-wallet with MIT License 5 votes vote down vote up
public static void initImageLoader(Context context) {

        ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
        config.threadPriority(Thread.NORM_PRIORITY - 2);
        config.denyCacheImageMultipleSizesInMemory();
        config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
        config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
        config.tasksProcessingOrder(QueueProcessingType.LIFO);
        config.writeDebugLogs(); // Remove for release app

        // Initialize ImageLoader with configuration.
        ImageLoader.getInstance().init(config.build());


    }
 
Example #29
Source File: App.java    From RxJavaApp with Apache License 2.0 5 votes vote down vote up
private void initImageLoader(Context context) {

        DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
                //.showImageForEmptyUri(R.drawable.ic_empty)
                //.showImageOnFail(R.drawable.ic_error)
                .resetViewBeforeLoading(true)
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .imageScaleType(ImageScaleType.EXACTLY)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .considerExifParams(true)
                .displayer(new FadeInBitmapDisplayer(300))
                .build();

        // This configuration tuning is custom. You can tune every option, you may tune some of them,
        // or you can create default configuration by
        //  ImageLoaderConfiguration.createDefault(this);
        // method.
        ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
        config.threadPriority(Thread.NORM_PRIORITY - 2);
        config.denyCacheImageMultipleSizesInMemory();
        config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
        config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
        config.tasksProcessingOrder(QueueProcessingType.LIFO);
        config.defaultDisplayImageOptions(defaultOptions);

        // Initialize ImageLoader with configuration.
        ImageLoader.getInstance().init(config.build());

    }
 
Example #30
Source File: CommodityItemAdapter.java    From MarketAndroidApp with Apache License 2.0 5 votes vote down vote up
public CommodityItemAdapter(Context mContext, List<CommodityModel> menuDatas, Handler handler) {
    this.mContext = mContext;
    this.menuDatas = menuDatas;
    this.mHandler = handler;

    //实例化ImageLoader
    ImageLoaderConfiguration configuration = ImageLoaderConfiguration.createDefault(mContext);
    ImageLoader.getInstance().init(configuration);
}