0

Following Fresco's documentations: http://frescolib.org/docs/listening-to-events.html

I've set up a listener to notify me on the events, but what I need to know (and could not find this information anywhere) is if the low-res calls will notify the listeners as well. And if so, how to avoid it, or set a different listener entirely for the low-res calls. For those wondering, Fresco can load a low-res version of an image before loading the high-res version, and this is how the callbacks are called on this is what is confusing me.

This is my code, for reference:

/*
   Here we create the controller, aggregating everything that has been done before and some other settings, and set the controller to our view.
*/

PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder();
builder.setLowResImageRequest(lowResRequest)
.setImageRequest(request)
.setTapToRetryEnabled(true)
.setControllerListener(controllerListener) // this is the callback listener
.setOldController(container.getController());
DraweeController controller = builder.build();

1 Answer 1

1

If you want to notify about the events of low res request, you need to add a RequestListener to low res request:

ImageRequestBuilder.fromRequest(request)
            .setRequestListener(requestListener)
            .build();

If the original image request loads faster than low res, Fresco will call the onRequestCancelation on low res image request listener.

2
  • I only want the events of the high-res request. And I do have a custom request for the high-res image as well. Should I set the listener there instead of setting it in the Controller? I'm a little confused to the differences between the controller listener and the request listener. Sep 25, 2017 at 19:50
  • Yes, you should set a listener on request, but request listeners are added globally registered in the ImagePipelineConfig and logs all requests. Check the differences on your link: frescolib.org/docs/listening-to-events.html I think you need the controller listener
    – bvarga
    Sep 25, 2017 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.