Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not show images in Glide #60

Open
Gamletus opened this issue Dec 13, 2017 · 0 comments
Open

Does not show images in Glide #60

Gamletus opened this issue Dec 13, 2017 · 0 comments

Comments

@Gamletus
Copy link

Gamletus commented Dec 13, 2017

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;
		}
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant