當前位置: 首頁>>代碼示例>>Java>>正文


Java ImagePipelineConfig.newBuilder方法代碼示例

本文整理匯總了Java中com.facebook.imagepipeline.core.ImagePipelineConfig.newBuilder方法的典型用法代碼示例。如果您正苦於以下問題:Java ImagePipelineConfig.newBuilder方法的具體用法?Java ImagePipelineConfig.newBuilder怎麽用?Java ImagePipelineConfig.newBuilder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.facebook.imagepipeline.core.ImagePipelineConfig的用法示例。


在下文中一共展示了ImagePipelineConfig.newBuilder方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    init();

    //初始化KLog
    KLog.init(BuildConfig.LOG_DEBUG);
    // fresco圖片庫的初始化
    ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(this);
    ImagePipelineConfig imagePipelineConfig = configBuilder.build();
    Fresco.initialize(this, imagePipelineConfig);

    /**
     * 如果存在SD卡則將緩存寫入SD卡,否則寫入手機內存
     */
    if (getApplicationContext().getExternalCacheDir() != null && ExistSDCard()) {
        cacheDir = getApplicationContext().getExternalCacheDir().toString();
    } else {
        cacheDir = getApplicationContext().getCacheDir().toString();
    }
}
 
開發者ID:ydmmocoo,項目名稱:StudyApp,代碼行數:23,代碼來源:App.java

示例2: getImagePipelineConfig

import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
 * Creates config using android http stack as network backend.
 */
public static ImagePipelineConfig getImagePipelineConfig(Context context) {
  if (sImagePipelineConfig == null) {
    ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(context);
    configureCaches(configBuilder, context);
    configureLoggingListeners(configBuilder);
    configureOptions(configBuilder);
    sImagePipelineConfig = configBuilder.build();
  }
  return sImagePipelineConfig;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:ImagePipelineConfigFactory.java

示例3: getImagePipelineConfig

import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
 * Creates config using android http stack as network backend.
 */
public static ImagePipelineConfig getImagePipelineConfig(Context context) {
    if (sImagePipelineConfig == null) {
        ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(context);
        configureCaches(configBuilder, context);
        sImagePipelineConfig = configBuilder.build();
    }
    return sImagePipelineConfig;
}
 
開發者ID:Elbehiry,項目名稱:Viajes,代碼行數:12,代碼來源:ImagePipelineConfigFactory.java

示例4: getImagePipelineConfig

import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
 * 初始化配置
 * Creates config using android http stack as network backend.
 */
public static ImagePipelineConfig getImagePipelineConfig(Context context) {
    if (sImagePipelineConfig == null) {
        ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(context);
        configureCaches(configBuilder, context);
        sImagePipelineConfig = configBuilder.build();
    }
    return sImagePipelineConfig;
}
 
開發者ID:LegendKe,項目名稱:MyTravelingDiary,代碼行數:13,代碼來源:ImagePipelineConfigFactory.java

示例5: getImagePipelineConfig

import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
   * Creates config using android http stack as network backend.
   */
  public static ImagePipelineConfig getImagePipelineConfig(Context context) {
    if (sImagePipelineConfig == null) {
      ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(context);
      configureCaches(configBuilder, context);
//      configureLoggingListeners(configBuilder);
      configureOptions(configBuilder);
      sImagePipelineConfig = configBuilder.build();
    }
    return sImagePipelineConfig;
  }
 
開發者ID:jiang111,項目名稱:ZhiHu-TopAnswer,代碼行數:14,代碼來源:ImagePipelineConfigFactory.java

示例6: getImagePipelineConfig

import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
 * Creates config using android http stack as network backend.
 */
public static ImagePipelineConfig getImagePipelineConfig(Context context) {
  if (sImagePipelineConfig == null) {
    ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(context);
    configureCaches(configBuilder, context);
    sImagePipelineConfig = configBuilder.build();
  }
  return sImagePipelineConfig;
}
 
開發者ID:iKnown,項目名稱:AndroidImageSelect,代碼行數:12,代碼來源:ImagePipelineConfigFactory.java

示例7: initFresco

import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
private void initFresco() {
  final ImagePipelineConfig.Builder configBuilder = ImagePipelineConfig.newBuilder(this);

  File cacheDir = getExternalCacheDir();
  if (cacheDir == null) {
    cacheDir = getCacheDir();
  }

  final DiskCacheConfig.Builder mainDiskCacheConfigBuilder = DiskCacheConfig.newBuilder(this);
  mainDiskCacheConfigBuilder.setBaseDirectoryName("image_cache");
  mainDiskCacheConfigBuilder.setBaseDirectoryPath(cacheDir);
  mainDiskCacheConfigBuilder.setMaxCacheSize(100 * 1024 * 1024);
  mainDiskCacheConfigBuilder.setVersion(1);
  configBuilder.setMainDiskCacheConfig(mainDiskCacheConfigBuilder.build());

  final ImagePipelineConfig.Builder config = ImagePipelineConfig.newBuilder(this);
  if (BuildConfig.DEBUG) {
    final Set<RequestListener> requestListeners = new HashSet<>();
    requestListeners.add(new RequestLoggingListener());
    config.setRequestListeners(requestListeners);

    FLog.setMinimumLoggingLevel(FLog.VERBOSE);
  }
  configBuilder.setMemoryTrimmableRegistry(frescoMemoryTrimmableRegistry);

  Fresco.initialize(this, config.build());
}
 
開發者ID:Shopify,項目名稱:mobile-buy-sdk-android,代碼行數:28,代碼來源:BaseApplication.java

示例8: configureCaches

import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
     * ImagePipeline配置
     *
     * @param context      context
     * @param okHttpClient okHttp客戶端
     * @return ImagePipeline配置實例
     */
    private static ImagePipelineConfig configureCaches(Context context, OkHttpClient okHttpClient, String cachePath) {
        //內存配置
        final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
                ConfigConstants.MAX_MEMORY_CACHE_SIZE,// 內存緩存中總圖片的最大大小,以字節為單位
                Integer.MAX_VALUE,// 內存緩存中圖片的最大數量
                ConfigConstants.MAX_MEMORY_CACHE_SIZE,// 內存緩存中準備清除但尚未被刪除的總圖片的最大大小,以字節為單位
                Integer.MAX_VALUE,// 內存緩存中準備清除的總圖片的最大數量
                Integer.MAX_VALUE);// 內存緩存中單個圖片的最大大小
        //修改內存圖片緩存數量,空間策略
        Supplier<MemoryCacheParams> mSupplierMemoryCacheParams = new Supplier<MemoryCacheParams>() {
            @Override
            public MemoryCacheParams get() {
                return bitmapCacheParams;
            }
        };
//        String cachePath = Environment.getExternalStorageDirectory().getAbsolutePath();//獲得存儲路徑(SDcard)
        String file = "fresco";
        //小圖片的磁盤配置
        DiskCacheConfig diskSmallCacheConfig = DiskCacheConfig.newBuilder(context)
                .setBaseDirectoryPath(new File(cachePath))//緩存圖片基路徑
                .setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_SMALL_CACHE_DIR)//文件夾名
//            .setCacheErrorLogger(cacheErrorLogger)//日誌記錄器用於日誌錯誤的緩存。
//            .setCacheEventListener(cacheEventListener)//緩存事件偵聽器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//類將包含一個注冊表的緩存減少磁盤空間的環境。
                .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默認緩存的最大大小。
                .setMaxCacheSizeOnLowDiskSpace(ConfigConstants.MAX_SMALL_DISK_CACHE_LOW_SIZE)//緩存的最大大小,使用設備時低磁盤空間。
                .setMaxCacheSizeOnVeryLowDiskSpace(ConfigConstants.MAX_SMALL_DISK_CACHE_VERY_LOW_SIZE)//緩存的最大大小,當設備極低磁盤空間
//            .setVersion(version)
                .build();
        //默認圖片的磁盤配置
        DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context)
                .setBaseDirectoryPath(new File(cachePath))//緩存圖片基路徑
                .setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_CACHE_DIR)//文件夾名
//            .setCacheErrorLogger(cacheErrorLogger)//日誌記錄器用於日誌錯誤的緩存。
//            .setCacheEventListener(cacheEventListener)//緩存事件偵聽器。
//            .setDiskTrimmableRegistry(diskTrimmableRegistry)//類將包含一個注冊表的緩存減少磁盤空間的環境。
                .setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)//默認緩存的最大大小。
                .setMaxCacheSizeOnLowDiskSpace(ConfigConstants.MAX_DISK_CACHE_LOW_SIZE)//緩存的最大大小,使用設備時低磁盤空間。
                .setMaxCacheSizeOnVeryLowDiskSpace(ConfigConstants.MAX_DISK_CACHE_VERY_LOW_SIZE)//緩存的最大大小,當設備極低磁盤空間
//            .setVersion(version)
                .build();
        //緩存圖片配置
        ImagePipelineConfig.Builder configBuilder = null;
        if (okHttpClient != null)
            configBuilder = OkHttpImagePipelineConfigFactory.newBuilder(context, okHttpClient);
        else
            configBuilder = ImagePipelineConfig.newBuilder(context);
//            .setAnimatedImageFactory(AnimatedImageFactory animatedImageFactory)//圖片加載動畫
        configBuilder.setBitmapMemoryCacheParamsSupplier(mSupplierMemoryCacheParams)//內存緩存配置(一級緩存,已解碼的圖片)
//            .setCacheKeyFactory(cacheKeyFactory)//緩存Key工廠
//            .setEncodedMemoryCacheParamsSupplier(encodedCacheParamsSupplier)//內存緩存和未解碼的內存緩存的配置(二級緩存)
//            .setExecutorSupplier(executorSupplier)//線程池配置
//            .setImageCacheStatsTracker(imageCacheStatsTracker)//統計緩存的命中率
//            .setImageDecoder(ImageDecoder imageDecoder) //圖片解碼器配置
//            .setIsPrefetchEnabledSupplier(Supplier<Boolean> isPrefetchEnabledSupplier)//圖片預覽(縮略圖,預加載圖等)預加載到文件緩存
                .setMainDiskCacheConfig(diskCacheConfig)//磁盤緩存配置(總,三級緩存)
//            .setMemoryTrimmableRegistry(memoryTrimmableRegistry) //內存用量的縮減,有時我們可能會想縮小內存用量。比如應用中有其他數據需要占用內存,不得不把圖片緩存清除或者減小 或者我們想檢查看看手機是否已經內存不夠了。
//            .setNetworkFetchProducer(networkFetchProducer)//自定的網絡層配置:如OkHttp,Volley
//            .setPoolFactory(poolFactory)//線程池工廠配置
                .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())//漸進式JPEG圖
//            .setRequestListeners(requestListeners)//圖片請求監聽
//            .setResizeAndRotateEnabledForNetwork(boolean resizeAndRotateEnabledForNetwork)//調整和旋轉是否支持網絡圖片
                .setSmallImageDiskCacheConfig(diskSmallCacheConfig);//磁盤緩存配置(小圖片,可選~三級緩存的小圖優化緩存)
        return configBuilder.build();
    }
 
開發者ID:Jusenr,項目名稱:androidtools,代碼行數:73,代碼來源:ImagePipelineFactory.java

示例9: init

import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
public static void init(Context context, OkHttpClient client) {

        ImagePipelineConfig.Builder config;

        if (client != null) {

            config = OkHttpImagePipelineConfigFactory.newBuilder(context, client);

        } else {

            config = ImagePipelineConfig.newBuilder(context);
        }

        // Enable down-sampling.
        config.setDownsampleEnabled(true);
        config.setWebpSupportEnabled(true);

        // Setup caches.
        configureCaches(config, context);

        // Initialize fresco.
        Fresco.initialize(context, config.build());
    }
 
開發者ID:mrkcsc,項目名稱:android-mg-bootstrap,代碼行數:24,代碼來源:MGImagesConfig.java


注:本文中的com.facebook.imagepipeline.core.ImagePipelineConfig.newBuilder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。