Giter VIP home page Giter VIP logo

Comments (4)

desmond1121 avatar desmond1121 commented on August 22, 2024

@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.

ChenSiLiang avatar ChenSiLiang commented on August 22, 2024

@desmond1121 的确,后来我也是这样解决的,但是预览帧也是需要做大图压缩,不然很容易引发OOM。然后我一直在研究在RecycleView里怎么整合这种方法,但是一直找不到一种正确回收Bitmap的方法,一旦Bitmap没有及时回收,也容易导致to much Bitmap的异常。
我也试过在RecycleView的生命周期方法里回收,但是它的重用机制比较复杂,又容易导致used a recycled Bitmap异常。
我最后选择在onBindViewHolder,绑定数据之前先赋值null.
谢谢您!

from fresco-source-analysis.

desmond1121 avatar desmond1121 commented on August 22, 2024

@ChenSiLiang 这个场景有点复杂,祝你好运~ 有啥图片加载方面的问题可以一起研究:)

from fresco-source-analysis.

ChenSiLiang avatar ChenSiLiang commented on August 22, 2024

@desmond1121 好的 谢谢 ;)

from fresco-source-analysis.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.