问题描述:

I am trying to use the picasso library to loading the image store in the mediastore. When I called load(imageview, callback), the picasso call onFail instead of onSuccess. How do I know why the image was not loaded successfully?

网友答案:

Use builder:

    Picasso.Builder builder = new Picasso.Builder(this);
    builder.listener(new Picasso.Listener()
    {
        @Override
        public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception)
        {
            exception.printStackTrace();
        }
    });
    builder.build().load(URL).into(imageView);
网友答案:

When you use callback, the picaso will call method onSuccess and onError!

File fileImage = new File(mPathImage);
        Picasso.with(mContext).load(fileImage)
                .placeholder(R.drawable.draw_detailed_view_display)
                .error(R.drawable.draw_detailed_view_display)
                .resize(200, 200)
                .into(holder.mImageEvidence, new Callback() {
                    @Override
                    public void onSuccess() {
                        holder.mMediaEvidencePb.setVisibility(View.GONE);
                    }

                    @Override
                    public void onError() {
                        holder.mErrorImage.setVisibility(View.VISIBLE);
                    }
                });
相关阅读:
Top