本文整理汇总了Java中com.facebook.imagepipeline.cache.MemoryCacheParams类的典型用法代码示例。如果您正苦于以下问题:Java MemoryCacheParams类的具体用法?Java MemoryCacheParams怎么用?Java MemoryCacheParams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MemoryCacheParams类属于com.facebook.imagepipeline.cache包,在下文中一共展示了MemoryCacheParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的package包/类
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
MemoryCacheParams params = new MemoryCacheParams(
4 * ByteConstants.MB,
256,
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
when(mMemoryCacheParamsSupplier.get()).thenReturn(params);
CountingMemoryCache<CacheKey, CloseableImage> countingMemoryCache =
BitmapCountingMemoryCacheFactory.get(
mMemoryCacheParamsSupplier,
mMemoryTrimmableRegistry,
mPlatformBitmapFactory,
true);
mCacheKey = new SimpleCacheKey("key");
mAnimatedFrameCache = new AnimatedFrameCache(mCacheKey, countingMemoryCache);
mFrame1 = CloseableReference.of(mock(CloseableImage.class));
mFrame2 = CloseableReference.of(mock(CloseableImage.class));
}
示例2: configureCaches
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的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());
}
示例3: configureCaches
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的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());
}
示例4: get
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的package包/类
@Override
public MemoryCacheParams get() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return new MemoryCacheParams(
getMaxCacheSize(),
Integer.MAX_VALUE,
getMaxCacheSize(),
Integer.MAX_VALUE,
Integer.MAX_VALUE);
}else {
return new MemoryCacheParams(
getMaxCacheSize(),
Integer.MAX_VALUE,
getMaxCacheSize(),
Integer.MAX_VALUE,
Integer.MAX_VALUE);
}
}
示例5: configureCaches
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的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());
}
示例6: getConfigureCaches
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的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();
}
示例7: initUtil
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的package包/类
private void initUtil() {
//初始化工具类
DBManager.initialInstance(new DBOpenHelper(mContext));
PermissionUtil.setContext(mContext);
MediaStoreUtil.setContext(mContext);
Util.setContext(mContext);
ImageUriUtil.setContext(mContext);
DiskCache.init(mContext);
ColorUtil.setContext(mContext);
PlayListUtil.setContext(mContext);
final int cacheSize = (int)(Runtime.getRuntime().maxMemory() / 8);
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
.setBitmapMemoryCacheParamsSupplier(() -> new MemoryCacheParams(cacheSize, Integer.MAX_VALUE,cacheSize,Integer.MAX_VALUE, 2 * ByteConstants.MB))
.setBitmapsConfig(Bitmap.Config.RGB_565)
.setDownsampleEnabled(true)
.build();
Fresco.initialize(this,config);
}
示例8: getImagePipelineConfig
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的package包/类
public static ImagePipelineConfig getImagePipelineConfig(Context context) {
if (sImagePipelineConfig == null) {
sImagePipelineConfig = ImagePipelineConfig.newBuilder(context)
.setMainDiskCacheConfig(DiskCacheConfig.newBuilder(context)
.setMaxCacheSize(ConfigConstants.MAX_CACHE_DISK_SIZE)
.build())
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
@Override
public MemoryCacheParams get() {
return new MemoryCacheParams(ConfigConstants.MAX_CACHE_MEMORY_SIZE,
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
}
}
)
.build();
}
return sImagePipelineConfig;
}
示例9: configureCaches
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的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());
}
示例10: configureCaches
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的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());
}
示例11: initFrescoConfig
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的package包/类
private void initFrescoConfig() {
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);
ImagePipelineConfig config = OkHttpImagePipelineConfigFactory.newBuilder(this, mOkHttpClient)
.setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
.setBitmapMemoryCacheParamsSupplier(new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(
DiskCacheConfig.newBuilder(this).setMaxCacheSize(MAX_DISK_CACHE_SIZE).build())
.setDownsampleEnabled(true)
.build();
Fresco.initialize(this, config);
}
示例12: configureCaches
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的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());
}
示例13: configureCaches
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的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());
}
示例14: get
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的package包/类
@Override
public MemoryCacheParams get() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return new MemoryCacheParams(getMaxCacheSize(), MAX_CACHE_ENTRIES, MAX_CACHE_EVICTION_SIZE, MAX_CACHE_EVICTION_ENTRIES, 1);
} else {
return new MemoryCacheParams(
getMaxCacheSize(),
MAX_CACHE_ASHM_ENTRIES,
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
}
}
示例15: init
import com.facebook.imagepipeline.cache.MemoryCacheParams; //导入依赖的package包/类
public void init(final Context context) {
final int MAX_HEAP_SIZE = (int) Runtime.getRuntime().maxMemory();
final int MAX_DISK_CACHE_SIZE = 300 * ByteConstants.MB;
final int MAX_MEMORY_CACHE_SIZE = MAX_HEAP_SIZE / 3;
final MemoryCacheParams bitmapCacheParams = new MemoryCacheParams(
MAX_MEMORY_CACHE_SIZE,
Integer.MAX_VALUE,
MAX_MEMORY_CACHE_SIZE,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
DiskCacheConfig diskCacheConfig = DiskCacheConfig.newBuilder(context)
.setMaxCacheSize(MAX_DISK_CACHE_SIZE)//最大缓存
.setBaseDirectoryName("udesk")//子目录
.setBaseDirectoryPathSupplier(new Supplier<File>() {
@Override
public File get() {
return UdeskUtil.getExternalCacheDir(context);
}
})
.build();
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(context)
.setBitmapMemoryCacheParamsSupplier(
new Supplier<MemoryCacheParams>() {
public MemoryCacheParams get() {
return bitmapCacheParams;
}
})
.setMainDiskCacheConfig(diskCacheConfig)
.setDownsampleEnabled(true)
.setBitmapsConfig(Bitmap.Config.RGB_565)
.build();
Fresco.initialize(context, config);
}