public abstract class OnThrottleClickListener implements View.OnClickListener { private static final int THROTTLE_CLICK_GAP_TIME = 300; private long preClickTime;
@Override public void onClick(View view) { // long currentTimeMillis = System.currentTimeMillis(); // long currentTimeMillis = Calendar.getInstance().getTimeInMillis(); long currentTimeMillis = SystemClock.uptimeMillis(); // long currentTimeMillis = SystemClock.elapsedRealtime(); if (currentTimeMillis - preClickTime > THROTTLE_CLICK_GAP_TIME) { onThrottleClick(view); preClickTime = currentTimeMillis; Log.d("cmf", "perform"); } else { Log.d("cmf", "break"); } }
public abstract void onThrottleClick(View view); }