Search code examples
androidparse-platformbaseadapterpicasso

Picasso only loading one image in a BaseAdapter


In the getView() of a BaseAdapter I load an image into a ImageView using a URL and Picasso. Unfortunately only one image is being loaded. Here is the getView() code :

 @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            LayoutInflater inflater = (LayoutInflater) mFragment.getActivity().getSystemService(Context
                    .LAYOUT_INFLATER_SERVICE);
            view = inflater.inflate(R.layout.layout_card, viewGroup, false);

        }


        Log.d("ParseUrl", mCardList.get(i).getProfilePictureFiles().get(0).getUrl());
        ImageView image = (ImageView) view.findViewById(R.id.image);

        Picasso.with(mFragment.getActivity()).load(mCardList.get(i).getProfilePictureFiles().get(0)
                .getUrl()).into(image);
        TextView name = (TextView) view.findViewById(R.id.name);
        name.setText(mCardList.get(i).getUser().getString(Keys.NAME_STR));

        return view;
    }

Some more strange behavior: If I try changing the URL to a static imgur image, only 2/3 are loaded, and when i refresh the fragment then all the images are loaded because they are cached.


Solution

  • When u fetch image from Parse Cloud that a time parse work on Thread so image is loaded but into catch memory so always use Picasso Lib so set its please holder with default image like..

    Picasso.with(mFragment.getActivity()).load(mCardList.get(i).getProfilePictureFiles().get(0).getUrl())                       .into(image).placeholder(R.drawable.ic_launcher);