Banner-Slider icon indicating copy to clipboard operation
Banner-Slider copied to clipboard

onSlideClicked returns a negative position

Open alisoleimani-android opened this issue 6 years ago • 1 comments

Hi, thanks for your awesome library i faced with a bug that when i have just one image in slider, and clicked event occurs , it returns a negative position (-2) .

ss.com.bannerslider.Slider slider = view.findViewById(R.id.slider); ss.com.bannerslider.Slider.init(new MySliderImageLoadingService(parent.getContext())); slider.setAdapter(new MySliderAdapter(sliders)); slider.setOnSlideClickListener(new OnSlideClickListener() { @Override public void onSlideClick(int position) { Slider slider = sliders.get(position); FunctionHelper.gotoLink(parent.getContext(), slider.getLinkType(),slider.getLink(),slider.getName()); } });

i find out this bug is from your getUserSlidePosition(int position)

public int getUserSlidePosition(int position) { if (loop) { if (position == 0) { return recyclerViewAdapter.getItemCount() - 3; } else if (position == recyclerViewAdapter.getItemCount() - 1) { return 0; } else { return position - 1; } } else { return position; } }

and i handled it with

if (sliders.size() > 1) { slider.setLoopSlides(true); } else if (sliders.size() == 1) { slider.setLoopSlides(false); }

alisoleimani-android avatar Apr 16 '18 11:04 alisoleimani-android

i have this issue too ! and i handle it with checking size of array exactly like you! but i think it should be better to handle by library

marjandn avatar Feb 06 '19 10:02 marjandn