AndroidImageSlider
AndroidImageSlider copied to clipboard
Using Glide instead of Picasso
I noticed the images stretch sometimes and do not re-size properly. I want to use Glide, how can I override Picasso so that I can use Glide?
+1 , same question
do this
public class GlideSliderView extends BaseSliderView { protected void bindEventAndShow(final View v, ImageView targetImageView) { v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mOnSliderClickListener != null) { mOnSliderClickListener.onSliderClick(GlideSliderView.this); } } });
if (targetImageView == null)
return;
if (mLoadListener != null) {
mLoadListener.onStart(this);
}
RequestManager p = (mGlide != null) ? mGlide : Glide.with(mContext);
DrawableTypeRequest rq = null;
if (mUrl != null) {
rq = p.load(mUrl);
} else if (mFile != null) {
rq = p.load(mFile);
} else if (mRes != 0) {
p.load(mRes);
} else {
return;
}
if (rq == null) {
return;
}
if (getEmpty() != 0) {
rq.placeholder(getEmpty());
}
if (getError() != 0) {
rq.error(getError());
}
v.findViewById(com.daimajia.slider.library.R.id.loading_bar).setVisibility(View.INVISIBLE);
rq.diskCacheStrategy(DiskCacheStrategy.ALL).thumbnail(0.1f).skipMemoryCache(true).centerCrop().into(targetImageView);
} }
This works only if you download the library, because you need to change some super properties from private to protected. But thanks anyway.
public class GlideSliderView extends DefaultSliderView {
public GlideSliderView(Context context) {
super(context);
}
protected void bindEventAndShow(final View v, ImageView targetImageView) {
View progressBar = v.findViewById(com.daimajia.slider.library.R.id.loading_bar);
if (progressBar != null) {
progressBar.setVisibility(View.GONE);
}
Glide.with(getContext())
.load(getUrl())
.centerCrop()
.crossFade()
.into(targetImageView);
}
}
its not working.images not loaded from url :(
can i load images from json? i've tried but the images not appear
Pull request #289 is an implementation that splits the library into a "picasso" and "glide" product type so that you can choose which image library to use. The demo app in that PR was changed over to use the glide implementation for testing/reference.
You can check this library https://github.com/OpenSooq/Pluto it has the ability to have full control over your views and layout and not depending on any image library