pans
2017-08-30 71c92f101b6c8b4a678a8c3cfe2d8edbf488efa4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package cn.com.basic.face.service;
 
import android.os.SystemClock;
 
public class PreventDoubleClick {
 
    private static long mLastClickTime = 0;
    private static int source = 0;
 
    public static boolean checkDoubleClick(int source) {
        if (source == PreventDoubleClick.source) {
            // mis-clicking prevention, using threshold of 1000 ms
            if (SystemClock.elapsedRealtime() - mLastClickTime < 1000){
                return true;
            }
        }
        PreventDoubleClick.source = source;
        mLastClickTime = SystemClock.elapsedRealtime();
        return false;
    }
 
}