touch block
setTouchable(false, 500);
//////////////////////////////////////
private boolean mIsTouchable = false;
private Handler mTouchHandler = new Handler();
private Runnable mTouchRelease = new Runnable(){
@Override
public void run() {
mIsTouchable = true;
}
};
public void setTouchable(boolean isTouchable, long touchLockTime){
if(!isTouchable && touchLockTime < 0){
return;
}
mIsTouchable = isTouchable;
if(!mIsTouchable && touchLockTime > 0){
mTouchHandler.removeCallbacks(mTouchRelease);
mTouchHandler.postDelayed(mTouchRelease, touchLockTime);
}
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if(!mIsTouchable){
return true;
}
return super.dispatchKeyEvent(event);
}
@Override
public boolean dispatchTouchEvent(MotionEvent arg0) {
if(!mIsTouchable){
return true;
}
return super.dispatchTouchEvent(arg0);
}