Android 多次点击

Posted by qkmin on March 25, 2020

Android 多次点击

final static int COUNTS = 5;// 点击次数
final static long DURATION = 2000;// 规定有效时间
long[] mHits = new long[COUNTS];
    
    
    
private void continuousClick(int count, long time) {
        //每次点击时,数组向前移动一位
        System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
        //为数组最后一位赋值
        mHits[mHits.length - 1] = SystemClock.uptimeMillis();
        if (mHits[0] >= (SystemClock.uptimeMillis() - DURATION)) {
            mHits = new long[COUNTS];//重新初始化数组
          
        }
    }