0

I'm using Fresco in a project, and I need to get the drawable resource of the image downloaded with it.

It's for the leanback BackgroundManager. It needs a drawable for change the background, but the image I'm getting is on the cloud.

I,ve seen examples with Glide, but no clue for Fresco. Any tips?

Glide.with(getActivity())
    .load(uri)
    .into(new SimpleTarget<GlideDrawable>(width, height) {
        @Override
        public void onResourceReady(GlideDrawable resource,
                                    GlideAnimation<? super GlideDrawable>
                                            glideAnimation) {
            mBackgroundManager.setDrawable(resource);
        }
    });
adalpari
  • 3,052
  • 20
  • 39
  • You may want to check [Listening to Download Events](http://frescolib.org/docs/listening-download-events.html#_) wherein it was stated that loading images is asynchronous. So you need some way of listening to events posted by the DraweeController. The mechanism for doing this is a controller listener. To use it, you merely define an instance of the `ControllerListener` interface. Subclassing `BaseControllerListener` was also recommended. Sample code can be found within the given link. – Teyam Feb 25 '17 at 16:32
  • This related [SO post](http://stackoverflow.com/questions/35682039/fresco-image-loading-callback) and [GitHub post](https://github.com/codepath/android_guides/wiki/Displaying-Images-with-the-Fresco-Library) might also help. – Teyam Feb 25 '17 at 16:32

0 Answers0