Java 类com.nostra13.universalimageloader.core.ImageLoaderConfiguration.Builder 实例源码

项目:EntboostIM    文件:MyApplication.java   
public void initEbConfig(String type) {
    Log4jLog.i(LONG_TAG, "initEbConfig start, type=" + type);

    CrashHandler crashHandler = CrashHandler.getInstance();
    crashHandler.init(getApplicationContext());

    Log4jLog.i(LONG_TAG, "initEbConfig 1");
    Entboost.setServiceListener(crashHandler);
    Log4jLog.i(LONG_TAG, "initEbConfig 2");
    Entboost.init(getApplicationContext());
    Log4jLog.i(LONG_TAG, "initEbConfig 3");
    Entboost.showSotpLog(false);
    Log4jLog.i(LONG_TAG, "initEbConfig 4");

    Builder imgConfig = new ImageLoaderConfiguration.Builder(this);
    imgConfig.threadPriority(Thread.NORM_PRIORITY - 2);// 设置线程的优先级
    imgConfig.diskCacheFileNameGenerator(new Md5FileNameGenerator());// 设置缓存文件的名字
    imgConfig.diskCacheSize(50 * 1024 * 1024); // 50 MiB
    imgConfig.denyCacheImageMultipleSizesInMemory();// 当同一个Uri获取不同大小的图片,缓存到内存时,只缓存一个。默认会缓存多个不同的大小的相同图片
    imgConfig.tasksProcessingOrder(QueueProcessingType.LIFO);// 设置图片下载和显示的工作队列排序
    ImageLoader.getInstance().init(imgConfig.build());

    defaultImgOptions = createImgOptions(R.drawable.entboost_logo, R.drawable.entboost_logo, R.drawable.entboost_logo);
    userImgOptions = createImgOptions(0, R.drawable.default_user, R.drawable.default_user);
    funcInfoImgOptions = createImgOptions(0, R.drawable.default_app, R.drawable.default_app);
}
项目:transdroid    文件:NavigationHelper.java   
private boolean checkPermission(final Activity activity, final String permission, final int requestCode) {
    if (hasPermission(permission))
        // Permission already granted
        return true;
    if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
        // Never asked again: show a dialog with an explanation
        activity.runOnUiThread(new Runnable() {
            public void run() {
                new MaterialDialog.Builder(context).content(R.string.permission_readtorrent).positiveText(android.R.string.ok)
                    .onPositive(new MaterialDialog.SingleButtonCallback() {
                        @Override
                        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                            ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
                        }
                    }).show();
            }
        });
        return false;
    }
    // Permission not granted (and we asked for it already before)
    ActivityCompat.requestPermissions(activity, new String[]{permission}, REQUEST_TORRENT_READ_PERMISSION);
    return false;
}
项目:transdroid    文件:NavigationHelper.java   
/**
 * Returns (and initialises, if needed) an image cache that uses memory and (1MB) local storage.
 * @return An image cache that loads web images synchronously and transparently
 */
public ImageLoader getImageCache() {
    if (imageCache == null) {
        imageCache = ImageLoader.getInstance();
        try {
            LruDiskCache diskCache = new LruDiskCache(context.getCacheDir(), null, new Md5FileNameGenerator(), 640000, 25);
            // @formatter:off
            Builder imageCacheBuilder = new Builder(context)
                    .defaultDisplayImageOptions(
                            new DisplayImageOptions.Builder()
                                    .cacheInMemory(true)
                                    .cacheOnDisk(true)
                                    .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
                                    .showImageForEmptyUri(R.drawable.ic_launcher).build())
                    .memoryCache(new UsingFreqLimitedMemoryCache(1024 * 1024))
                    .diskCache(diskCache);
            imageCache.init(imageCacheBuilder.build());
        // @formatter:on
        } catch (IOException e) {
            // The cache directory is always available on Android; ignore this exception
        }
    }
    return imageCache;
}
项目:letv    文件:LemallPlatform.java   
private static void initImageLoader(Context context) {
    Builder config = new Builder(context);
    config.threadPoolSize(3);
    config.memoryCache(new WeakMemoryCache());
    config.memoryCacheSize(2097152);
    config.discCacheSize(100);
    config.threadPriority(3);
    config.denyCacheImageMultipleSizesInMemory();
    config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
    config.diskCacheSize(ConfigurationBuild.DEFAULT_DEFAULT_SDCARD_SIZE);
    config.tasksProcessingOrder(QueueProcessingType.LIFO);
    config.writeDebugLogs();
    ImageLoader.getInstance().init(config.build());
}
项目:boohee_v5.6    文件:UILImageLoader.java   
private void initImageLoader(Context context) {
    if (!ImageLoader.getInstance().isInited()) {
        ImageLoader.getInstance().init(new Builder(context.getApplicationContext())
                .threadPoolSize(3).defaultDisplayImageOptions(new DisplayImageOptions.Builder
                        ().cacheInMemory(true).cacheOnDisk(true).build()).build());
    }
}
项目:boohee_v5.6    文件:UILImageLoader.java   
public void displayImage(MQImageView imageView, String path, @DrawableRes int loadingResId,
                         @DrawableRes int failResId, int width, int height, final
                         MQDisplayImageListener displayImageListener) {
    initImageLoader(imageView.getContext());
    if (path == null) {
        path = "";
    }
    if (!(path.startsWith("http") || path.startsWith("file"))) {
        path = "file://" + path;
    }
    String str = path;
    ImageLoader.getInstance().displayImage(str, new ImageViewAware(imageView), new
            DisplayImageOptions.Builder().showImageOnLoading(loadingResId).showImageOnFail
            (failResId).cacheInMemory(true).build(), new ImageSize(width, height), new
            SimpleImageLoadingListener() {
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            if (displayImageListener != null) {
                displayImageListener.onSuccess(view, imageUri);
            }
        }
    }, null);
}
项目:EntboostIM    文件:MyApplication.java   
private DisplayImageOptions createImgOptions(int loadingResid, int emptyResid, int failResid) {
    DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder();
    builder.cacheInMemory(true)
        .cacheOnDisk(true)
        .considerExifParams(true)
        .bitmapConfig(Bitmap.Config.RGB_565);
    if (loadingResid!=0)
        builder.showImageOnLoading(loadingResid);
    if (failResid!=0)
        builder.showImageOnFail(failResid);
    if (emptyResid!=0)
        builder.showImageForEmptyUri(emptyResid);

    return builder.build();
}
项目:letv    文件:LetvCacheConfiguration.java   
public static void initCacheLibrary(Context context, LetvThumbnailUtils thumbnailUtils) {
    ImageLoader.getInstance().init(new Builder(context).memoryCache(getMemoryCache(context)).diskCache(getDiscCache()).threadPoolSize(3).threadPriority(3).denyCacheImageMultipleSizesInMemory().imageDownloader(new BaseImageDownloader(context)).tasksProcessingOrder(QueueProcessingType.LIFO).setThumbnailUtils(thumbnailUtils).writeDebugLogs().build());
}
项目:boohee_v5.6    文件:MyApplication.java   
public static void initImageLoader(Context context) {
    ImageLoader.getInstance().init(new Builder(context).threadPriority(3)
            .denyCacheImageMultipleSizesInMemory().discCacheFileNameGenerator(new
                    Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO)
            .defaultDisplayImageOptions(ImageLoaderOptions.randomColor()).build());
}