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

How to use Glide #11

Closed
erfannf opened this issue Feb 26, 2018 · 3 comments
Closed

How to use Glide #11

erfannf opened this issue Feb 26, 2018 · 3 comments
Labels

Comments

@erfannf
Copy link

erfannf commented Feb 26, 2018

I'v inspected examples and found the complex models utilizing Glide. By the way RENDERER is deprecated in latest release and I can not figure out how to use Glide in BINDERS. Any help?

@vivchar
Copy link
Owner

vivchar commented Feb 26, 2018

Good question! Thanks.

In my project I am using a CustomView, example:

public class UrlImageView extend ImageView {

	public UrlImageView(Context context) { /* default constructor */
		super(context);
	}

	/* other methods */

	public void setUrl(String url) {
		Glide.with(getContext()).load(url).into(this);
	}
}
mRecyclerViewAdapter.registerRenderer(new ViewBinder<>(
	R.layout.item_layout,
	SomeModel.class,
	(model, finder, payloads) -> finder
		.find(R.id.custom_view, (ViewProvider<UrlImageView>) urlImageView -> {
			urlImageView.setUrl(model.getImageUrl());
		})
));

OR you can use it:

mRecyclerViewAdapter.registerRenderer(new ViewBinder<>(
	R.layout.item_layout,
	SomeModel.class,
	(model, finder, payloads) -> finder
		.find(R.id.custom_view, (ViewProvider<ImageView>) imageView -> {
			Glide.with(getContext()).load(model.getUrl()).into(imageView);
		})
));

OR:

mRecyclerViewAdapter.registerRenderer(new ViewBinder<>(
	R.layout.item_layout,
	SomeModel.class,
	(model, finder, payloads) -> finder {
		ImageView imageView = finder.find(R.id.custom_view);
		Glide.with(getContext()).load(model.getUrl()).into(imageView);
	}
));

@DuarteBarbosaPT
Copy link

DuarteBarbosaPT commented Mar 28, 2018

Just a small correction
there's a 's' missing in extend (public class UrlImageView extend ImageView {)

I have this error:
android.support.v7.widget.AppCompatImageView cannot be cast to net.quarkapps.ezmeet.customViews.UrlImageView

Edit: I just used another example but I had to use finder.getRootView().getContext()

@vivchar
Copy link
Owner

vivchar commented Mar 29, 2018

android.support.v7.widget.AppCompatImageView cannot be cast to net.quarkapps.ezmeet.customViews.UrlImageView

Looks like you did not replace the AppCompatImageView to the UrlImageView in your xml layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants