1. 程式人生 > >工具類:防抖動(極短時間多次點選,導致介面彈出多個dialog)

工具類:防抖動(極短時間多次點選,導致介面彈出多個dialog)

工具類:

public class OnClickUtils {
    // 兩次點選按鈕之間的點選間隔不能少於500毫秒
    private static final int MIN_CLICK_DELAY_TIME = 500;
    private static long lastClickTime;

    public static boolean isFastClick() {
        boolean flag = false;
        long curClickTime = System.currentTimeMillis();
        if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) {
            flag = true;
        }
        lastClickTime = curClickTime;
        return flag;
    }
}