0

I am trying to show a loading icon when the image hasn't loaded yet and hide the loading icon when the image is ready. I am using Fresco library and I used the code below successfully to implement what I want:

private void loadImage(ImageView imageview,final ImageView videoicon, final GifTextView progressbar, Uri uri,final boolean video,final boolean child,boolean isConnectivity)
    { 
        if (child)
        {
            if (isConnectivity)
            progressbar.setBackgroundResource(Theme.Icons.LoadingChild);
        }
        else
        {
            progressbar.setBackgroundResource(Theme.Icons.LoadingMain);
        }
        SimpleDraweeView imageDrawee = (SimpleDraweeView) imageview;

        ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
            @Override
            public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable anim) {
                if (imageInfo == null) {
                    return;
                }
                progressbar.setVisibility(View.GONE);
                if (video)
                {
                    if (child)
                    {
                        videoicon.setImageResource(Theme.Icons.MediaGalleryVideoIcon);
                    }
                    else
                    {
                        linearlayout_mediagalleryvideoicon.setVisibility(View.VISIBLE);
                        videoicon.setImageResource(Theme.Icons.MediaGalleryVideoIcon);
                    }
                }
            }

            @Override
            public void onIntermediateImageSet(String id, @Nullable ImageInfo imageInfo) {
                //FLog.d("Intermediate image received");
            }

            @Override
            public void onFailure(String id, Throwable throwable) {
                //FLog.e(getClass(), throwable, "Error loading %s", id)
            }
        };


        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setControllerListener(controllerListener)
                .setOldController(imageDrawee.getController())
                .setUri(uri)
                .build();
        imageDrawee.setController(controller); 
    }

My problem is that when I close the Fragment, I can see from the Android Monitor that the DraweeController continue using CPU. When I open 20-30 Fragment that contain one image, my application crashes because of heavy CPU load.

How to overcome this problem?

stavros.3p
  • 2,244
  • 6
  • 20
  • 37

1 Answers1

0

The problem wasn't with Fresco library, but with the library I used to display GIF images.

stavros.3p
  • 2,244
  • 6
  • 20
  • 37