第一次错误装载的画面,毕加索 [英] First time error loading picture with Picasso

查看:191
本文介绍了第一次错误装载的画面,毕加索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动 ImagePagerAdapter (延伸 FragmentStatePagerAdapter )具有此的getItem 方法:

I have an Activity with an ImagePagerAdapter (extends of FragmentStatePagerAdapter) that has this getItem method:

@Override
        public Fragment getItem(int position) {
            Log.d(LOGTAG, "------------>mUserPicturesList.get("+position+").getFilename(): " + mUserPicturesList.get(position).getFilename());
            return UserDetailFragment.newInstance(mUserPicturesList.get(position).getFilename());
        }

这被实例化的片段有这样onCreateView:

The fragment that is instantiated has this onCreateView:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate and locate the main ImageView
    final View v = inflater.inflate(R.layout.image_detail_fragment, container, false);
    mImageView = (ImageView) v.findViewById(R.id.imageView);
    mProgressPicturePager = (ProgressBar) v.findViewById(R.id.progress_picture_pager);

    String imageUrl = WApp.PHOTO_URL + mImageUrl + "?type=user_gallery_big_img";

    Picasso picasso = Picasso.with(getActivity());
    picasso.setDebugging(true);
    picasso.load(imageUrl)
            .placeholder(R.drawable.no_picture_man_big)
            .error(android.R.drawable.stat_notify_error)
            .into(mImageView, new Callback() {
                @Override
                public void onSuccess() {
                    mProgressPicturePager.setVisibility(View.GONE);
                }

                @Override
                public void onError() {
                    Log.d(LOGTAG, "picasso load error");
                    mProgressPicturePager.setVisibility(View.GONE);
                }
            });

    return v;
}

的问题:

ImagePager 加载第一次,有些时候,毕加索呼叫的onError ,显示 .error 绘制。 如果我$背部按钮p $ PSS和返回到活动具有 ImagePager ,毕加索加载图片正确。 如果 ImagePager 有两个或两个以上的照片,我刷的图像之间,这些都是正确加载有时不退出并重新进入到 ImagePager

When the ImagePager load first time, some times, Picasso call onError, showing the .error drawable. If I press on back button and go back to the Activity that has the ImagePager, Picasso load the picture correctly. If the ImagePager has two or more pictures and I swipe between the pictures, those are loaded correctly some times without exit and reenter to the ImagePager.

的理论:

我想这可能是缓存的问题,但很多搜索后,我敢打赌,这个问题是在毕加索的弱引用。 请记住,这个问题仅出现在我第一次加载有ImagePager活动。

I think that it could be a problem of cache, but after many searches, I bet that the problem is in the weak reference of the Picasso. Keep in mind that the problem only appears the FIRST TIME I load the activity that have the ImagePager.

在另外一个地方,目前毕加索工作正常,在的ListView 通过一个适配器加载图片的第一次。呼叫毕加索 适配器 getView 法里面类。

In another place, currently Picasso works fine in listView with an adapter loading the pictures at first time. Calling Picasso inside the getView method of Adapter class.

访问过的链接

  • <一个href="http://stackoverflow.com/questions/20505494/how-would-an-anonymous-class-get-gcd-in-picasso-on-android">How将一个匿名类获得GC'd毕加索在Android?
  • <一个href="http://stackoverflow.com/questions/21647533/viewpager-unable-to-load-images-lazily-with-picasso">ViewPager无法加载图像懒洋洋地与毕加索
  • http://square.github.io/picasso/
  • <一个href="https://plus.google.com/communities/109244258569782858265/stream/885843f4-c8b5-4851-9de1-b0374121dfa3" rel="nofollow">https://plus.google.com/communities/109244258569782858265/stream/885843f4-c8b5-4851-9de1-b0374121dfa3
  • 使用对象的适配器上
  • https://github.com/square/picasso/pull/349
  • How would an anonymous class get GC'd in picasso on Android?
  • ViewPager unable to load images lazily with Picasso
  • http://square.github.io/picasso/
  • https://plus.google.com/communities/109244258569782858265/stream/885843f4-c8b5-4851-9de1-b0374121dfa3
  • Use of Target in Picasso on Adapter
  • https://github.com/square/picasso/pull/349

在此先感谢。

推荐答案

这个问题是解决了毕加索2.3.0。

The problem was solved in the Picasso 2.3.0.

解决方法是在毕加索的changelog

申请将现在如果他们没有被自动重播由于网络错误。

Requests will now be automatically replayed if they failed due to network errors.

我希望这为您节省很多时间。

I hope this save you many hours.

这篇关于第一次错误装载的画面,毕加索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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