com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator Java Examples

The following examples show how to use com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator. 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: 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 #2
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 #3
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 #4
Source File: MyApplication.java    From AndroidCacheFoundation with Apache License 2.0 6 votes vote down vote up
/**
 * Universal Image Loader Setup
 */
private void setupUIL() {
    File cacheDir = StorageUtils.getOwnCacheDirectory(
            getApplicationContext(), "CafeCar/cache");
    options = new DisplayImageOptions.Builder()
            .cacheOnDisc(true).cacheInMemory(true).build();
    cache = new TotalSizeLimitedDiscCache(cacheDir, 50 * 1024 * 1024);
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            getApplicationContext()).threadPoolSize(3)
            .threadPriority(Thread.NORM_PRIORITY - 1)
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024))
                    // You can pass your own memory cache implementation
            .discCache(cache)
                    // You can pass your own disc cache implementation
            .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
            .defaultDisplayImageOptions(options).build();
    ImageLoader.getInstance().init(config);
}
 
Example #5
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 #6
Source File: ImageLoaderConfig.java    From fitness_Android with Apache License 2.0 5 votes vote down vote up
/**
 * 异步图片加载ImageLoader的初始化操作,在Application中调用此方法
 * 
 * @param context
 *            上下文对象
 * @param cacheDisc
 *            图片缓存到SDCard的目录,只需要传入SDCard根目录下的子目录即可,默认会建立在SDcard的根目录下
 */
public static void initImageLoader(Context context, String cacheDisc) {
	
	// 配置ImageLoader
	// 获取本地缓存的目录,该目录在SDCard的根目录下
	File cacheDir = StorageUtils.getOwnCacheDirectory(context, cacheDisc);
	// 实例化Builder
	ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(
			context);
	// 设置线程数量
	builder.threadPoolSize(3);
	// 设定线程等级比普通低一点
	builder.threadPriority(Thread.NORM_PRIORITY);
	// 设定内存缓存为弱缓存
	builder.memoryCache(new WeakMemoryCache());
	// 设定内存图片缓存大小限制,不设置默认为屏幕的宽高
	builder.memoryCacheExtraOptions(480, 800);
	// 设定只保存同一尺寸的图片在内存
	builder.denyCacheImageMultipleSizesInMemory();
	// 设定缓存的SDcard目录,UnlimitDiscCache速度最快
	builder.discCache(new UnlimitedDiscCache(cacheDir));
	// 设定缓存到SDCard目录的文件命名
	builder.discCacheFileNameGenerator(new HashCodeFileNameGenerator());
	// 设定网络连接超时 timeout: 10s 读取网络连接超时read timeout: 60s
	builder.imageDownloader(new BaseImageDownloader(context, 10000, 60000));
	// 设置ImageLoader的配置参数
	builder.defaultDisplayImageOptions(initDisplayOptions(true));

	// 初始化ImageLoader
	ImageLoader.getInstance().init(builder.build());
}
 
Example #7
Source File: FragmentUser.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
private void uploadImgByBitmap(final Bitmap bitmap, final String mimeType) {
    if (mDialogSearching == null) {
        mDialogSearching = new DialogSearching(getActivity());
    }
    mDialogSearching.setContent(R.string.z_toast_modifying);
    mDialogSearching.show();
    new Handler().post(new Runnable() {
                           @Override
                           public void run() {
                               new Thread() {
                                   @Override
                                   public void run() {
                                       Message msg = new Message();
                                       msg.what = 1;
                                       msg.obj = null;
                                       try {
                                           BaseResponse<String> base = new Gson().fromJson((String) FormFile.postDatas(CommonUtils.getImageByteByBitmap(bitmap),
                                                   mimeType), new TypeToken<BaseResponse<String>>() {
                                           }.getType());
                                           msg.obj = base;
                                           if (base.error_code == 0) {
                                               String fileName = new HashCodeFileNameGenerator().generate(base.data);
                                               MediaStoreUtils.copyFile(mImagePath, SdCacheTools.getOwnImageCacheDir(mContext) + "/" + fileName);
                                           }
                                       } catch (Throwable e) {
                                           e.printStackTrace();
                                           msg.obj = null;
                                       }
                                       mHanlder.sendMessage(msg);
                                   }
                               }.start();
                           }
                       }

    );
}
 
Example #8
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 #9
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 #10
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 #11
Source File: DefaultConfigurationFactory.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
/** Creates {@linkplain HashCodeFileNameGenerator default implementation} of FileNameGenerator */
public static FileNameGenerator createFileNameGenerator() {
	return new HashCodeFileNameGenerator();
}
 
Example #12
Source File: FragmentUser.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
private void uploadImg() {
    if (mDialogSearching == null) {
        mDialogSearching = new DialogSearching(getActivity());
    }
    mDialogSearching.setContent(R.string.z_toast_modifying);
    mDialogSearching.show();
    new Handler().post(new Runnable() {
                           @Override
                           public void run() {
                               new Thread() {
                                   @Override
                                   public void run() {
                                       Message msg = new Message();
                                       msg.what = 1;
                                       msg.obj = null;
                                       try {
                                           ImageSize imageSize = BaseImageDecoder.getImageSize(mImagePath);
                                           BaseResponse<String> base = new Gson().fromJson((String) FormFile.postDatas(CommonUtils.getImageByteByPath(mImagePath, imageSize),
                                                   imageSize == null ? null : imageSize.getMimeType()), new TypeToken<BaseResponse<String>>() {
                                           }.getType());
                                           msg.obj = base;
                                           if (base.error_code == 0) {
                                               String fileName = new HashCodeFileNameGenerator().generate(base.data);
                                               MediaStoreUtils.copyFile(mImagePath, SdCacheTools.getOwnImageCacheDir(mContext) + "/" + fileName);
                                               File file = new File(mImagePath);
                                               if (!file.exists()) {
                                                   file.delete();
                                               }
                                           }
                                       } catch (Throwable e) {
                                           e.printStackTrace();
                                           msg.obj = null;
                                       }
                                       mHanlder.sendMessage(msg);
                                   }
                               }.start();
                           }
                       }

    );
}
 
Example #13
Source File: DefaultConfigurationFactory.java    From mobile-manager-tool with MIT License 4 votes vote down vote up
/** Creates {@linkplain com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator default implementation} of FileNameGenerator */
public static FileNameGenerator createFileNameGenerator() {
	return new HashCodeFileNameGenerator();
}
 
Example #14
Source File: DefaultConfigurationFactory.java    From WliveTV with Apache License 2.0 4 votes vote down vote up
/** Creates {@linkplain HashCodeFileNameGenerator default implementation} of FileNameGenerator */
public static FileNameGenerator createFileNameGenerator() {
	return new HashCodeFileNameGenerator();
}
 
Example #15
Source File: ImageLoaderSetting.java    From Pas with Apache License 2.0 4 votes vote down vote up
public static void initImageLoader(Context context) {

        // 设置缓存 路径
        File cacheDir = StorageUtils.getOwnCacheDirectory(context,
                "eh2h/imageloader/Cache");

        //默认
        defaultOptions = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.mipmap.defaultbg)
                .showImageForEmptyUri(R.mipmap.defaultbg)
                .showImageOnFail(R.mipmap.defaultbg)
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .considerExifParams(true)
                .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default
                        //.displayer(new FadeInBitmapDisplayer(300, true, true, true))
                        //.displayer(new RoundedBitmapDisplayer(90))
                .delayBeforeLoading(100)//载入图片前稍做延时可以提高整体滑动的流畅度
                .bitmapConfig(Bitmap.Config.RGB_565).build();



        animateFirstListener = new AnimateFirstDisplayListener();


        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
                .diskCacheExtraOptions(480, 800, null)
                .threadPoolSize(3) // default
                .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 UnlimitedDiskCache(cacheDir)) // default
                .diskCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(100)
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
               // .writeDebugLogs()
                .build();


        ImageLoader.getInstance().init(config);
    }
 
Example #16
Source File: ImageLoaderSetting.java    From Pas with Apache License 2.0 4 votes vote down vote up
public static void initImageLoader(Context context) {

        // 设置缓存 路径
        File cacheDir = StorageUtils.getOwnCacheDirectory(context,
                "eh2h/imageloader/Cache");

        //默认
        defaultOptions = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.mipmap.ic_launcher)
                .showImageForEmptyUri(R.mipmap.ic_launcher)
                .showImageOnFail(R.mipmap.ic_launcher)
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .considerExifParams(true)
                .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default
                        //.displayer(new FadeInBitmapDisplayer(300, true, true, true))
                        //.displayer(new RoundedBitmapDisplayer(90))
                .delayBeforeLoading(100)//载入图片前稍做延时可以提高整体滑动的流畅度
                .bitmapConfig(Bitmap.Config.RGB_565).build();



        animateFirstListener = new AnimateFirstDisplayListener();


        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
                .diskCacheExtraOptions(480, 800, null)
                .threadPoolSize(3) // default
                .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 UnlimitedDiskCache(cacheDir)) // default
                .diskCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(100)
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
               // .writeDebugLogs()
                .build();


        ImageLoader.getInstance().init(config);
    }
 
Example #17
Source File: DefaultConfigurationFactory.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public static FileNameGenerator createFileNameGenerator()
{
    return new HashCodeFileNameGenerator();
}
 
Example #18
Source File: DefaultConfigurationFactory.java    From letv with Apache License 2.0 4 votes vote down vote up
public static FileNameGenerator createFileNameGenerator() {
    return new HashCodeFileNameGenerator();
}
 
Example #19
Source File: DefaultConfigurationFactory.java    From android-open-project-demo with Apache License 2.0 4 votes vote down vote up
/** Creates {@linkplain HashCodeFileNameGenerator default implementation} of FileNameGenerator */
public static FileNameGenerator createFileNameGenerator() {
	return new HashCodeFileNameGenerator();
}
 
Example #20
Source File: DefaultConfigurationFactory.java    From candybar with Apache License 2.0 4 votes vote down vote up
/**
 * Creates {@linkplain HashCodeFileNameGenerator default implementation} of FileNameGenerator
 */
public static FileNameGenerator createFileNameGenerator() {
    return new HashCodeFileNameGenerator();
}
 
Example #21
Source File: DefaultConfigurationFactory.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 2 votes vote down vote up
/**
 * Creates {@linkplain HashCodeFileNameGenerator default implementation} of FileNameGenerator
 * 文件名称生成
 */
public static FileNameGenerator createFileNameGenerator() {
	return new HashCodeFileNameGenerator();
}