I have used daimajia/AndroidImageSlider library. How can i set Different Duration for Different Images ?? is it possible to set different duration for images ?? For instance if there are two Categories of Images, category A duration will be 15 sec and category B will be 5 sec
for (String name : url_maps.keySet()) {
customSliderView = null;
customSliderView = new CustomSliderView(getApplicationContext());
// initialize a SliderLayout
customSliderView
//.description(name)
.image(url_maps.get(name))
.setScaleType(BaseSliderView.ScaleType.CenterCrop);
//.setOnSliderClickListener(this);
mDemoSlider.addSlider(customSliderView);
}
mDemoSlider.setPresetTransformer(SliderLayout.Transformer.DepthPage);
mDemoSlider.setDuration(MY_DURATION);
mDemoSlider.startAutoCycle(MY_DURATION, MY_DURATION, true);
So, After lot of trial and error I've achieved what I intended to do. I had to turn off auto cycle and swap slider manually after 17 seconds and 3 seconds periodically. Pls let me know if there is any better solution.
for (String name : url_maps.keySet()) {
//textSliderView = null;
customSliderView = null;
//textSliderView = new TextSliderView(getApplicationContext());
customSliderView = new CustomSliderView(getApplicationContext());
// initialize a SliderLayout
customSliderView
//.description(name)
.image(url_maps.get(name))
.setScaleType(BaseSliderView.ScaleType.CenterCrop);
//.setOnSliderClickListener(this);
mDemoSlider.addSlider(customSliderView);
}
mDemoSlider.setPresetTransformer(SliderLayout.Transformer.DepthPage);
//mDemoSlider.setDuration(MY_DURATION);
mDemoSlider.destroyDrawingCache();
mDemoSlider.setDrawingCacheEnabled(false);
mDemoSlider.clearDisappearingChildren();
mDemoSlider.stopAutoCycle();
//mDemoSlider.startAutoCycle(MY_DURATION, MY_DURATION, true);
//mDemoSlider.addOnPageChangeListener(this);
And then 2 function for swapping
private void initViewPager() {
//sendRequest();
//callAsynchronousTask();
callTimer1();
}
private void callTimer1() {
// Auto start of viewpager
final Runnable Update = new Runnable() {
public void run() {
//viewPager.setCurrentItem(1, true);
//mDemoSlider.moveNextPosition(true);
mDemoSlider.setCurrentPosition(0, true);
}
};
final Timer swipeTimer = new Timer();
swipeTimer.schedule(new TimerTask() {
@Override
public void run() {
handler.post(Update);
swipeTimer.cancel();
callTimer2();
}
}, 3500, 17000);
}
private void callTimer2() {
final Runnable Update = new Runnable() {
public void run() {
//viewPager.setCurrentItem(0, true);
mDemoSlider.setCurrentPosition(1, true);
//mDemoSlider.moveNextPosition(true);
}
};
final Timer swipeTimer2 = new Timer();
swipeTimer2.schedule(new TimerTask() {
@Override
public void run() {
handler.post(Update);
swipeTimer2.cancel();
callTimer1();
}
}, 17000, 3500);
}