Android - Picasso misses pictures sometimes

社会主义新天地 提交于 2019-12-24 13:38:18

问题


I am using Picasso library for images downloading using the following code, I've to load many pictures in a loop by resizing them and transforming to circular. Sometimes images are successfully loaded and sometimes onError method is called instead of onSuccess in Callback. And i get this error SkImageDecoder::Factory returned null Error. When i uninstall the app then after reinstalling images are loaded successfully mostly. What is the problem exactly and kindly suggest any solution.

Code:

int dp = (int) resources.getDimension(R.dimen.marker_pic_size);
    Picasso.with(context).load(profilePic_url)
            .transform(new CircleTransform())
            .resize(dp, dp)
            .into(tempView, new Callback() {
                @Override
                public void onSuccess() {
                Log.d("usm_onSuccess", profilePic_url);   
                  }

                @Override
                public void onError() {
                    Log.d("usm_onError", profilePic_url);
                }
            });

回答1:


By the use of Target it may solve you problem.

target = new Target() {
@Override
public void onPrepareLoad(Drawable drawable) {}

@Override
public void onBitmapLoaded(Bitmap bitmap, LoadedFrom arg1) {
    if(bitmap != null) {
        tempView.setImageBitmap(bitmap);
    }
}

@Override
public void onBitmapFailed(Drawable drawable) {}
};

...

int dp = (int) resources.getDimension(R.dimen.marker_pic_size);
    Picasso.with(context).load(profilePic_url)
            .transform(new CircleTransform())
            .resize(dp, dp)
            .into(target);
tempView.setTag(target);

It is know issue.You may also see this to get more idea.



来源:https://stackoverflow.com/questions/35433895/android-picasso-misses-pictures-sometimes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!