package tech.starwin.impl;

import android.view.View;

/**
 * Created by SiKang on 2018/9/18.
 * 防抖 ClickListener
 */
public abstract class OnNoShakeClickListener extends OnEventClickListener {

    public int lockTime = 2000;

    public OnNoShakeClickListener(int milliSencons) {
        lockTime = milliSencons;
    }

    public OnNoShakeClickListener() {
    }

    @Override
    public final void onClick(final View v) {
        super.onClick(v);
        v.setClickable(false);
        v.setLongClickable(false);
        v.postDelayed(new Runnable() {
            @Override
            public void run() {
                v.setClickable(true);
            }
        }, lockTime);
        onEventClick(v);
    }

}
