package com.ym.modulecommon.base

import android.os.SystemClock
import android.view.View

/**
 * Created by erwin on 2020/11/19
 */
abstract class NoDoubleClickListener : View.OnClickListener {

    private val MIN_CLICK_DELAY_TIME:Long = 2000
    private var lastClickTime: Int = 0

    override fun onClick(p0: View?) {
        val currentTime: Long = SystemClock.elapsedRealtime()
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime.toInt()
            onNoDoubleClick(p0)
        }
    }

    abstract fun onNoDoubleClick(view: View?)
}