【问题标题】:How to use both onSuccess() and onBitmapLoaded() with Picasso如何在 Picasso 中同时使用 onSuccess() 和 onBitmapLoaded()
【发布时间】:2019-01-03 22:01:10
【问题描述】:

我正在设计要在交错布局中显示的图像。所以,我使用 Target 的 onBitmapLoaded() 方法来保持纵横比。

picasso.load(mCursor.getString(ArticleLoader.Query.THUMB_URL))
                .placeholder(R.drawable.photo_background_protection)
                .into(new Target() {


            @Override
            public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                float width = bitmap.getWidth();
                float height = bitmap.getHeight();

                float aspectRatio = width / height;

                holder.thumbnailView.setAspectRatio(aspectRatio);
                holder.thumbnailView.setImageBitmap(bitmap);
                holder.imageProgressBar.setVisibility(View.INVISIBLE);

            }

        });

我想调用onSuccess方法来检查图片是否加载成功,这样可以让progessBar不可见。

【问题讨论】:

    标签: android picasso


    【解决方案1】:

    您可以使用另一个“.into()”首先检查图像是否已加载。

    第二个答案可能对你有用:Android picasso check if image url exist before load into imageView

    【讨论】:

    • 它没有帮助。我不能调用 .into() 两次,所以我不能调用 onBitmapLoaded() AND onSuccess()。
    • @IgorGreccoLacourt 我没有问题可以调用Picasso.get()... .into() 两次嵌套 回调,并且不意味着直接访问.into() 而没有Picasso.get() 前缀。
    猜你喜欢
    • 2014-11-16
    • 1970-01-01
    • 2016-02-08
    • 1970-01-01
    • 2017-11-20
    • 2011-07-27
    • 1970-01-01
    • 2015-11-09
    • 2020-10-09
    相关资源
    最近更新 更多