Comments (1)
解决OOM问题,自测已没问题,初始化Fresco时,要添加如下内容:
private void initFresco() {
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
ImagePipelineConfig imagePipelineConfig = ImagePipelineConfig
.newBuilder(getApplicationContext())
.setDownsampleEnabled(true)
.setBitmapMemoryCacheParamsSupplier(new LollipopBitmapMemoryCacheParamsSupplier(activityManager))
.build();
Fresco.initialize(getApplicationContext(), imagePipelineConfig);
}
public class LollipopBitmapMemoryCacheParamsSupplier implements Supplier {
private ActivityManager activityManager;
public LollipopBitmapMemoryCacheParamsSupplier(ActivityManager activityManager) {
this.activityManager = activityManager;
}
@Override
public MemoryCacheParams get() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return new MemoryCacheParams(getMaxCacheSize(), 56, Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
// 不确定用哪个
// return new MemoryCacheParams(getMaxCacheSize(), 1, 1, 1, 1);
} else {
return new MemoryCacheParams(
getMaxCacheSize(),
256,
Integer.MAX_VALUE,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
}
}
private int getMaxCacheSize() {
final int maxMemory = Math.min(activityManager.getMemoryClass() * ByteConstants.MB, Integer.MAX_VALUE);
if (maxMemory < 32 * ByteConstants.MB) {
return 4 * ByteConstants.MB;
} else if (maxMemory < 64 * ByteConstants.MB) {
return 6 * ByteConstants.MB;
} else {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD) {
return 8 * ByteConstants.MB;
} else {
return maxMemory / 4;
}
}
}
}
from android-multiple-images-selector.
Related Issues (20)
- 为什么有时构建会特别慢
- 引用依赖包后报依赖包重复
- Limit exceed issue HOT 1
- library is not working HOT 3
- Android7.0 打开相机崩溃 HOT 5
- Error:(252, 5) error: duplicate value for resource 'attr/rfs_barColor' with config ''.
- FileUriExposedException HOT 3
- Problem occurred while generate signed apk
- not showing all images from gallery HOT 7
- set language english default HOT 1
- 上次选中过后的照片本地图片库里面没有了
- 为什么本地文件图片删除改变了,查询本地图片依然还能读出来
- Uri is getting null HOT 1
- Signed apk not working HOT 1
- EXIF Data Missing
- java.lang.UnsatisfiedLinkError: HOT 3
- Images not show in Android version 10
- lang
- CAMERA NOT WROKING HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-multiple-images-selector.