Android-Image-Slider
Android-Image-Slider copied to clipboard
setCurrentPageListener method not working
When I set the "setCurrentPageListener" of the Slider view it doesn't detect when the page is changed, this is my code in the onCreate method of my activity:
if (getIntent().getExtras() != null) {
int index = getIntent().getExtras().getInt("index", 0);
final ArrayList < MediaInfo > mediaInfoList = getIntent().getExtras().getParcelableArrayList("mediaList");
sliderView.setSliderAdapter(new SliderAdapter(mediaInfoList));
sliderView.setCurrentPageListener(new CircularSliderHandle.CurrentPageListener() {
@Override
public void onCurrentPageChanged(int currentPosition) {
//This never runs
Toast.makeText(MediaActivity.this, "Current page" + currentPosition, Toast.LENGTH_SHORT).show();
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(mediaInfoList.get(currentPosition).getSenderName());
getSupportActionBar().setSubtitle(String.valueOf(mediaInfoList.get(currentPosition).getTimestamp()));
}
}
});
sliderView.setCurrentPagePosition(index);
}
And in the xml file: `<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.activity.MediaActivity">
<com.smarteist.autoimageslider.SliderView
android:id="@+id/imageSlider"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:sliderAutoCycleEnabled="false"
app:sliderCircularHandlerEnabled="false"
app:sliderIndicatorAnimationDuration="500"
app:sliderIndicatorGravity="center_horizontal|bottom"
app:sliderIndicatorMargin="15dp"
app:sliderIndicatorOrientation="horizontal"
app:sliderIndicatorPadding="3dp"
app:sliderIndicatorRadius="2dp"
app:sliderIndicatorSelectedColor="@color/colorPrimary"
app:sliderIndicatorUnselectedColor="#FFF"
app:sliderScrollTimeInSec="1" />
</LinearLayout>`
Everything else is working fine, the only issue I am having is this listener.
When I set the "setCurrentPageListener" of the Slider view it doesn't detect when the page is changed, this is my code in the onCreate method of my activity:
if (getIntent().getExtras() != null) { int index = getIntent().getExtras().getInt("index", 0); final ArrayList < MediaInfo > mediaInfoList = getIntent().getExtras().getParcelableArrayList("mediaList"); sliderView.setSliderAdapter(new SliderAdapter(mediaInfoList)); sliderView.setCurrentPageListener(new CircularSliderHandle.CurrentPageListener() { @Override public void onCurrentPageChanged(int currentPosition) { //This never runs Toast.makeText(MediaActivity.this, "Current page" + currentPosition, Toast.LENGTH_SHORT).show(); if (getSupportActionBar() != null) { getSupportActionBar().setTitle(mediaInfoList.get(currentPosition).getSenderName()); getSupportActionBar().setSubtitle(String.valueOf(mediaInfoList.get(currentPosition).getTimestamp())); } } }); sliderView.setCurrentPagePosition(index); }And in the xml file: `
<com.smarteist.autoimageslider.SliderView android:id="@+id/imageSlider" android:layout_width="match_parent" android:layout_height="match_parent" app:sliderAutoCycleEnabled="false" app:sliderCircularHandlerEnabled="false" app:sliderIndicatorAnimationDuration="500" app:sliderIndicatorGravity="center_horizontal|bottom" app:sliderIndicatorMargin="15dp" app:sliderIndicatorOrientation="horizontal" app:sliderIndicatorPadding="3dp" app:sliderIndicatorRadius="2dp" app:sliderIndicatorSelectedColor="@color/colorPrimary" app:sliderIndicatorUnselectedColor="#FFF" app:sliderScrollTimeInSec="1" />`
Everything else is working fine, the only issue I am having is this listener.
Please update to 1.3.5 and tell me the result.