本文整理匯總了Java中com.facebook.imagepipeline.core.ImagePipelineConfig.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java ImagePipelineConfig.Builder方法的具體用法?Java ImagePipelineConfig.Builder怎麽用?Java ImagePipelineConfig.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.imagepipeline.core.ImagePipelineConfig
的用法示例。
在下文中一共展示了ImagePipelineConfig.Builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
private void init(Context context) {
ImagePipelineConfig.Builder builder = ImagePipelineConfig.newBuilder(context)
.setDownsampleEnabled(true);
String cache = BoxingFileHelper.getCacheDir(context);
if (TextUtils.isEmpty(cache)) {
throw new IllegalStateException("the cache dir is null");
}
if (cache != null) {
DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context)
.setBaseDirectoryPath(new File(cache))
.setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(MAX_DISK_CACHE_SIZE)
.setMaxCacheSizeOnLowDiskSpace(MAX_DISK_CACHE_LOW_SIZE)
.setMaxCacheSizeOnVeryLowDiskSpace(MAX_DISK_CACHE_VERYLOW_SIZE)
.build();
builder.setMainDiskCacheConfig(diskCacheConfig);
}
ImagePipelineConfig config = builder.build();
Fresco.initialize(context, config);
}
示例2: onCreate
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
final Config config = Config.load(this);
ImagePipelineConfig.Builder imagePipelineConfigBuilder = ImagePipelineConfig.newBuilder(this)
.setResizeAndRotateEnabledForNetwork(false)
.setDownsampleEnabled(config.downsampling);
if (WebpSupportStatus.sIsWebpSupportRequired) {
imagePipelineConfigBuilder.experiment().setWebpSupportEnabled(config.webpSupportEnabled);
}
if (config.decodingThreadCount == 0) {
imagePipelineConfigBuilder.setExecutorSupplier(
new DefaultExecutorSupplier(Const.NUMBER_OF_PROCESSORS));
} else {
imagePipelineConfigBuilder.setExecutorSupplier(
new ScrollPerfExecutorSupplier(Const.NUMBER_OF_PROCESSORS, config.decodingThreadCount));
}
imagePipelineConfigBuilder.experiment().setDecodeCancellationEnabled(config.decodeCancellation);
DraweeConfig draweeConfig = DraweeConfig.newBuilder()
.setDrawDebugOverlay(config.draweeOverlayEnabled)
.build();
Fresco.initialize(this, imagePipelineConfigBuilder.build(), draweeConfig);
}
示例3: getDefaultConfigBuilder
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
* Get the default Fresco configuration builder.
* Allows adding of configuration options in addition to the default values.
*
* @return {@link ImagePipelineConfig.Builder} that has been initialized with default values
*/
public static ImagePipelineConfig.Builder getDefaultConfigBuilder(ReactContext context) {
HashSet<RequestListener> requestListeners = new HashSet<>();
requestListeners.add(new SystraceRequestListener());
OkHttpClient client = OkHttpClientProvider.createClient();
// make sure to forward cookies for any requests via the okHttpClient
// so that image requests to endpoints that use cookies still work
CookieJarContainer container = (CookieJarContainer) client.cookieJar();
ForwardingCookieHandler handler = new ForwardingCookieHandler(context);
container.setCookieJar(new JavaNetCookieJar(handler));
return OkHttpImagePipelineConfigFactory
.newBuilder(context.getApplicationContext(), client)
.setNetworkFetcher(new ReactOkHttpNetworkFetcher(client))
.setDownsampleEnabled(false)
.setRequestListeners(requestListeners);
}
示例4: configureCaches
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
* Configures disk and memory cache not to exceed common limits
*/
private static void configureCaches(ImagePipelineConfig.Builder configBuilder, Context context) {
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
Integer.MAX_VALUE, // Max entries in the cache
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
Integer.MAX_VALUE, // Max length of eviction queue
Integer.MAX_VALUE); // Max cache entry size
configBuilder
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(DiskCacheConfig.newBuilder(context)
.setBaseDirectoryPath(getExternalCacheDir(context))
.setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(MAX_DISK_CACHE_SIZE)
.build());
}
示例5: configureCaches
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
* Configures disk and memory cache not to exceed common limits
*/
private static void configureCaches(
ImagePipelineConfig.Builder configBuilder,
Context context) {
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
Integer.MAX_VALUE, // Max entries in the cache
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
Integer.MAX_VALUE, // Max length of eviction queue
Integer.MAX_VALUE); // Max cache entry size
configBuilder
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(
DiskCacheConfig.newBuilder(context)
.setBaseDirectoryPath(context.getApplicationContext().getCacheDir())
.setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(MAX_DISK_CACHE_SIZE)
.build());
}
示例6: getDefaultConfig
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
private static ImagePipelineConfig getDefaultConfig(
Context context,
@Nullable RequestListener listener,
@Nullable DiskCacheConfig diskCacheConfig) {
HashSet<RequestListener> requestListeners = new HashSet<>();
requestListeners.add(new SystraceRequestListener());
if (listener != null) {
requestListeners.add(listener);
}
OkHttpClient okHttpClient = OkHttpClientProvider.getOkHttpClient();
ImagePipelineConfig.Builder builder =
OkHttpImagePipelineConfigFactory.newBuilder(context.getApplicationContext(), okHttpClient);
builder
.setDownsampleEnabled(false)
.setRequestListeners(requestListeners);
if (diskCacheConfig != null) {
builder.setMainDiskCacheConfig(diskCacheConfig);
}
return builder.build();
}
示例7: configureCaches
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
* Configures disk and memory cache not to exceed common limits
*/
private static void configureCaches(ImagePipelineConfig.Builder configBuilder, Context context) {
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
Integer.MAX_VALUE, // Max entries in the cache
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
Integer.MAX_VALUE, // Max length of eviction queue
Integer.MAX_VALUE); // Max cache entry size
configBuilder
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(DiskCacheConfig.newBuilder(context)
.setBaseDirectoryPath(getExternalCacheDir(context))
.setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(MAX_DISK_CACHE_SIZE)
.build());
}
示例8: onCreate
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
OkHttpClient okHttpClient = new OkHttpClient();
File sd = Environment.getExternalStorageDirectory();
String image = sd.getPath() + "/imageLoad";
//配置圖片緩存目錄
File cacheDir = new File(image);
if (!cacheDir.exists()) {
Log.i("App", "path:" + cacheDir.getAbsolutePath());
}
//初始化Fresco,使用OkHttp3作為網絡請求
ImagePipelineConfig.Builder configBuilder = FrescoConfig
.getConfigBuilder(getApplicationContext(), cacheDir, okHttpClient);
Fresco.initialize(this, configBuilder.build());
}
示例9: getConfigureCaches
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
private ImagePipelineConfig getConfigureCaches(Context context) {
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
MAX_MEM,// 內存緩存中總圖片的最大大小,以字節為單位。
Integer.MAX_VALUE,// 內存緩存中圖片的最大數量。
MAX_MEM,// 內存緩存中準備清除但尚未被刪除的總圖片的最大大小,以字節為單位。
Integer.MAX_VALUE,// 內存緩存中準備清除的總圖片的最大數量。
Integer.MAX_VALUE / 10);// 內存緩存中單個圖片的最大大小。
Supplier<MemoryCacheParams> mSupplierMemoryCacheParams = new Supplier<MemoryCacheParams>() {
@Override
public MemoryCacheParams get() {
return bitmapCacheParams;
}
};
ImagePipelineConfig.Builder builder = ImagePipelineConfig.newBuilder(context)
.setDownsampleEnabled(true);
builder.setBitmapMemoryCacheParamsSupplier(mSupplierMemoryCacheParams);
return builder.build();
}
示例10: 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();
}
}
示例11: configureCaches
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
* Configures disk and memory cache not to exceed common limits
*/
private static void configureCaches(
ImagePipelineConfig.Builder configBuilder,
Context context) {
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
Integer.MAX_VALUE, // Max entries in the cache
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
Integer.MAX_VALUE, // Max length of eviction queue
Integer.MAX_VALUE); // Max cache entry size
configBuilder
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(
DiskCacheConfig.newBuilder(context)
.setBaseDirectoryPath(context.getApplicationContext().getCacheDir())
.setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(MAX_DISK_CACHE_SIZE)
.build());
}
示例12: configureCaches
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
* Configures disk and memory cache not to exceed common limits
*/
private static void configureCaches(
ImagePipelineConfig.Builder configBuilder,
Context context) {
FileUtils.createDirs(ConfigConstants.IMAGE_PIPELINE_CACHE_DIR);
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
ConfigConstants.MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
Integer.MAX_VALUE, // Max entries in the cache
ConfigConstants.MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
Integer.MAX_VALUE, // Max length of eviction queue
Integer.MAX_VALUE); // Max cache entry size
configBuilder
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(
DiskCacheConfig.newBuilder(context)
.setBaseDirectoryPath(FileUtils.createDirs(ConfigConstants.IMAGE_PIPELINE_BASE_DIR))
.setBaseDirectoryName(ConfigConstants.IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)
.build());
}
示例13: configureCaches
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
* Configures disk and memory cache not to exceed common limits
*/
private static void configureCaches(ImagePipelineConfig.Builder configBuilder, Context context) {
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
Integer.MAX_VALUE, // Max entries in the cache
MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
Integer.MAX_VALUE, // Max length of eviction queue
Integer.MAX_VALUE); // Max cache entry size
configBuilder
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(DiskCacheConfig.newBuilder()
.setBaseDirectoryPath(getExternalCacheDir(context))
.setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(MAX_DISK_CACHE_SIZE)
.build());
}
示例14: configureCaches
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
/**
* Configures disk and memory cache not to exceed common limits
*/
private static void configureCaches(
ImagePipelineConfig.Builder configBuilder,
Context context) {
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
ConfigConstants.MAX_MEMORY_CACHE_SIZE, // Max total size of elements in the cache
Integer.MAX_VALUE, // Max entries in the cache
ConfigConstants.MAX_MEMORY_CACHE_SIZE, // Max total size of elements in eviction queue
Integer.MAX_VALUE, // Max length of eviction queue
Integer.MAX_VALUE); // Max cache entry size
configBuilder
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(
DiskCacheConfig.newBuilder(context)
.setBaseDirectoryPath(context.getApplicationContext().getCacheDir())
.setBaseDirectoryName(IMAGE_PIPELINE_CACHE_DIR)
.setMaxCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE)
.build());
}
示例15: setUp
import com.facebook.imagepipeline.core.ImagePipelineConfig; //導入方法依賴的package包/類
@Override
@Before
public void setUp() {
mInstrumentation = InstrumentationRegistry.getInstrumentation();
mWebpBitmapFactory = new WebpBitmapFactoryImpl();
ImagePipelineConfig.Builder configBuilder =
ImagePipelineConfig.newBuilder(mInstrumentation.getContext())
.experiment().setWebpBitmapFactory(mWebpBitmapFactory);
ImagePipelineFactory.initialize(configBuilder.build());
}