在毕加索获取与回调的图像? [英] Fetch images with Callback in Picasso?

查看:129
本文介绍了在毕加索获取与回调的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示的照片系列在中间的照片,其中照片以规则的间隔改变没有空隙。我意识到毕加索初始化的ImageView就开始下载之前,它总是这样做,不管我取()还是不调用到前()。

I want to show a photo series with no gaps in-between the photos, where photos change in a regular interval. I realized Picasso initializes the ImageView before it starts downloading, and it always does that, no matter if I fetch() or not before calling into().

予取(),以保持图像之间的间隙小,也可以使用.placeholder(R.color.black),但该间隙仍可见,即使当图像被从存储器加载

I fetch() to keep the gap between images small and also use .placeholder(R.color.black), but the gap is still visible, even when the image is loaded from memory.

我的code看起来像这样

My code looks like this

Picasso.with(getContext()).load(url).fetch();

然后用延迟[这是目前固定和我想调整依赖于网速]

then with a delay [which is currently fix and which I want to adjust dependent on network speed]

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

我注意到,取()不支持任何回调参数和返回void,所以现在看来​​,这是不可能的,我知道什么时候该缓存升温。

I noticed that fetch() does not support any callback parameters and returns void, so it seems it's not possible for me to know when the cache is warmed.

两个问题:

  1. 我可以让别人注意到当图像被缓存?
  2. 是否有可能以不同的方式来摆脱图像之间的休息时间,让他们定期出现。

[我知道我可以手动$ C C此$不知何故,但如果毕加索支持的话,我想使用它。]

[I know I could manually code this somehow, but if Picasso supports it, I'd like to use it.]

推荐答案

根据<一href="https://github.com/square/picasso/blob/master/picasso/src/main/java/com/squareup/picasso/FetchAction.java">the来源,它看起来像读取不执行任何操作完成后,包括通知任何潜在的听众。不幸的是, FetchAction 不是一个公共类,所以你不能覆盖此功能,无论是。

Based on the source, it looks like fetch does nothing upon completion, including notifying any potential listeners. Unfortunately, FetchAction isn't a public class, so you can't override this functionality either.

您可以通过使用自定义目标的子类,像这样的解决此问题:

You can workaround this problem by using a custom Target subclass, like this:

Picasso.with(getContext()).load(url).into(new Target() {
    @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
        // cache is now warmed up
    }
    @Override public void onBitmapFailed(Drawable errorDrawable) { }
    @Override public void onPrepareLoad(Drawable placeHolderDrawable) { }
});

这篇关于在毕加索获取与回调的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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