android - View Pager in Recycler View fast sliding glitch -
adapter implementation straight-forward
private context context; private string images[]; public pageradapter(context context) { this.context = context; } public void setimages(string images[]) { this.images = images; notifydatasetchanged(); } public boolean arearraythesame(string images[]) { return arrays.equals(this.images, images); } @override public int getcount() { if (images != null) { return images.length; } else { return 0; } } @override public boolean isviewfromobject(view view, object object) { return view == object; } @override public object instantiateitem(viewgroup container, final int position) { view itemview = layoutinflater.from(context).inflate(r.layout.cover_image_item, container, false); imageview imageview = (imageview) itemview.findviewbyid(r.id.coverimageiv); glide.with(context).load(images[position]).into(imageview); container.addview(itemview); return itemview; } @override public void destroyitem(viewgroup container, int position, object object) { container.removeview((view) object); }
recycler view initiate , load holder once
mpageradapter.setimages(coverpictures); mviewpager.setadapter(adapter); mcircleindicator.setviewpager(mviewpager);
and glitch weird. first time, slides okay, when scroll down , view holder, first time slide becomes glitchy. skips sliding, making view appear immediately. although further slides become fine. scrolling recycler-view down , creates same scenario.
any suggestions?
Comments
Post a Comment