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

前端 未结 7 1227
不知归路
不知归路 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:28

    Square lately has updated Target class and now there are more methods to override (onPrepareLoad and onBitmapFailed):

    Target target = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
        }
    
        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
    
        }
    
        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
    
        }
    };
    

    And you still have to use:

    Picasso.with(context).load(url).into(target);
    

提交回复
热议问题