Skip to content

Does not show images in Glide #60

Description

@Gamletus

1. Place the standard GridView-adapter is used in the footer (or header);
2. Add Glide to this adapter with the settings as in the code below.

After this, a problem arises: no images are displayed

@Override
protected void onCreate(Bundle savedInstanceState)
	{
	GridViewWithHeaderAndFooter numberGridView = (GridViewWithHeaderAndFooter) findViewById(R.id.number_view);

	LayoutInflater layoutIn = LayoutInflater.from(this);
	View footerView = layoutIn.inflate(R.layout.footer_view, null);

	GridView photoGridView = (GridView) footerView.findViewById(R.id.photo_view);
	photoGridView.setAdapter(new PhotoAdapter(this, photoList)); // photoList - ArrayList<String> list of photo names

	numberGridView.addFooterView(footerView);
	numberGridView.setAdapter(null);
	}

private class PhotoAdapter extends BaseAdapter
	{
	Context myContext;
	List<String> myPhoto;
	LayoutInflater myLayout;
	ImageView myPhotoView;

	private PhotoAdapter(Context contextView, List<String> photoList)
		{
		myPhoto = photoList;
		myContext = contextView;
		myLayout = LayoutInflater.from(contextView);
		}

	@Override
	public int getCount()
		{
		return myPhoto.size();
		}

	@Override
	public Object getItem(int position)
		{
		return myPhoto.get(position);
		}

	@Override
	public long getItemId(int position)
		{
		return position;
		}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
		{
		View view = convertView;
		if (view == null)
			{
			view = myLayout.inflate(R.layout.photo_view_item, parent, false);
			}

		myPhotoView = (ImageView) view.findViewById(R.id.photo_item);

		Glide
		.with(myContext)
		.load("http://site.ru/photos/" + getItem(position) + ".jpg")
		.diskCacheStrategy(DiskCacheStrategy.NONE) // IMPORTANT (IT IS NECESSARY)
		.skipMemoryCache(true) // IMPORTANT (IT IS NECESSARY)
		.into(myPhotoView);

		return view;
		}
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions