Comments (4)
@ChenSiLiang 我看了你在Fresco的issue,老外可能觉得你会oom不告诉你方法= = 这个问题我这几天看下来有一种解决方法,亲测可行:
ControllerListener listener = new BaseControllerListener<ImageInfo>(){
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable
animatable) {
super.onFinalImageSet(id, imageInfo, animatable);
if(imageInfo instanceof CloseableAnimatedImage){
AnimatedImageResult result = ((CloseableAnimatedImage) imageInfo).getImageResult();
if(result == null) return;
AnimatedImage image = result.getImage();
if(image != null){
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bmp = Bitmap.createBitmap(100, 100, conf);
image.getFrame(0).renderFrame(100, 100, bmp); //这里获取到你需要的Bitmap,我设置的是第0帧。 尺寸需要和创建的Bitmap相同
imageView.setImageBitmap(bmp);
}
}
}
};
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri("your uri")
.setAutoPlayAnimations(true)
.setControllerListener(listener)
.build();
SimpleDraweeView view = (SimpleDraweeView) findViewById(R.id.drawee_view);
view.setController(controller);
from fresco-source-analysis.
@desmond1121 的确,后来我也是这样解决的,但是预览帧也是需要做大图压缩,不然很容易引发OOM。然后我一直在研究在RecycleView
里怎么整合这种方法,但是一直找不到一种正确回收Bitmap
的方法,一旦Bitmap
没有及时回收,也容易导致to much Bitmap
的异常。
我也试过在RecycleView
的生命周期方法里回收,但是它的重用机制比较复杂,又容易导致used a recycled Bitmap
异常。
我最后选择在onBindViewHolder
,绑定数据之前先赋值null
.
谢谢您!
from fresco-source-analysis.
@ChenSiLiang 这个场景有点复杂,祝你好运~ 有啥图片加载方面的问题可以一起研究:)
from fresco-source-analysis.
@desmond1121 好的 谢谢 ;)
from fresco-source-analysis.
Related Issues (10)
- fresco编解码的具体方案? HOT 2
- 关于Fresco缓存的疑问 HOT 1
- 如何获取控件的图片转化为Bitmap HOT 5
- fresco从缓存或者网络加载数据的cancel机制的疑问 HOT 2
- 请问如何在不清除缓存的情况下,强制直接从网络加载图片呢 HOT 1
- 发现 (3)(4)(5) md 的语法有些问题
- 图片链接失效 HOT 3
- 图片加载链接又失效了 HOT 2
- 图片链接失效了
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 fresco-source-analysis.