How to listen for Picasso (Android) load complete events?

前端 未结 7 1234
不知归路
不知归路 2020-12-02 14:11

Is there a way to listen for events from Picasso when using the builder like:

Picasso.with(getContext()).load(url).into(imageView);

I\'m trying

7条回答
  •  渐次进展
    2020-12-02 14:37

    Answering @Jas follow up question as a comment to MrEngineer13's answer (since I don't have enough reputation to comment in any answer), you should use the error() method prior to registering the Callback at the into() method, for example:

    Picasso.with(getContext())
        .load(url)
        .error(R.drawable.error_placeholder_image)
        .into(imageView, new com.squareup.picasso.Callback() {
            @Override
            public void onSuccess() {
                //Success image already loaded into the view
            }
    
            @Override
            public void onError() {
                //Error placeholder image already loaded into the view, do further handling of this situation here
            }
        }
    );
    

提交回复
热议问题