Skip to content

Commit 0ffe973

Browse files
committed
getCurrenPosition
1 parent b70a4ba commit 0ffe973

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

library/src/main/java/com/daimajia/slider/library/SliderLayout.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,14 +588,27 @@ private SliderAdapter getRealAdapter(){
588588
return null;
589589
}
590590

591+
/**
592+
* get the current item position
593+
* @return
594+
*/
595+
public int getCurrentPosition(){
596+
597+
if(getRealAdapter() == null)
598+
throw new IllegalStateException("You did not set a slider adapter");
599+
600+
return mViewPager.getCurrentItem() % getRealAdapter().getCount();
601+
602+
}
603+
591604
/**
592605
* get current slider.
593606
* @return
594607
*/
595608
public BaseSliderView getCurrentSlider(){
596609

597610
if(getRealAdapter() == null)
598-
return null;
611+
throw new IllegalStateException("You did not set a slider adapter");
599612

600613
int count = getRealAdapter().getCount();
601614
int realCount = mViewPager.getCurrentItem() % count;

0 commit comments

Comments
 (0)