美文网首页
2秒内防止快速点击的实现

2秒内防止快速点击的实现

作者: GaoXiaoGao | 来源:发表于2019-02-26 10:29 被阅读0次

public class FastClickUtils {

private static final int MIN_CLICK_DELAY_TIME =2000;

    private static long lastClickTime;

    public static boolean isFastClick() {

boolean flag;

        long curClickTime = System.currentTimeMillis();

        if ((curClickTime -lastClickTime) >=MIN_CLICK_DELAY_TIME) {

                flag =false;

        }else{

                    flag =true;

        }

                lastClickTime = curClickTime;

                return flag;

    }

}

相关文章

网友评论

      本文标题:2秒内防止快速点击的实现

      本文链接:https://www.haomeiwen.com/subject/pqnoyqtx.html