如何收听Picasso(Android)加载完整的事件? [英] How to listen for Picasso (Android) load complete events?

查看:307
本文介绍了如何收听Picasso(Android)加载完整的事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在使用构建器时监听Picasso的事件,如:

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

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

我正在尝试调用 requestLayout() GridView 上$ c>和 invalidate()所以它会正确调整大小,但我不知道如何设置监听器或回调。

I'm trying to call requestLayout() and invalidate() on the parent GridView so it'll resize properly but I don't know how to set a listener or callback.

我看到Picasso有错误事件报告,但有成功事件吗?

I see that Picasso has error event reporting, but is there a success event?

推荐答案

您可以使用 Callback 来获取onSuccess和onError事件。只需为您的请求添加一个新的回调,如下所示:

You can use a Callback to get onSuccess and onError events. Just add a new Callback to your request like so:

Picasso.with(getContext())
    .load(url)
    .into(imageView, new com.squareup.picasso.Callback() {
                        @Override
                        public void onSuccess() {

                        }

                        @Override
                        public void onError(Exception ex) {

                        }
                    });

然后您可以在onSuccess回调中执行任何更改和修改。

Then you can perform any alterations and modifications in the onSuccess callback.

这篇关于如何收听Picasso(Android)加载完整的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆