I have a slidingdrawer in my activity, i open sliding drawer on swipe gesture from bottom to top what i want is to close that opened drawer after some second or delay let say after 5 seconds. How can i do that?
private class GestureDetector extends SimpleOnGestureListener {
SlidingDrawer drawer;
Timer timer;
public GestureDetector(SlidingDrawer drawer) {
this.drawer = drawer;
timer = new Timer();
}
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
closeSlider();
}
};
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if(e1.getY() > e2.getY()) {
this.drawer.animateOpen();
timer.scheduleAtFixedRate( timerTask , 0, 3000);
} else {
//this.drawer.animateClose();
}
}
public void closeSlider() {
this.drawer.animateClose();
}
}
//i call it on activity onCreate()
SlidingDrawer slidingDrawer = (SlidingDrawer) findViewById(R.id.slidingDrawer);
new GestureDetector(slidingDrawer);
Thanking you