android重复点击问题
open class SingleClickListener(private val intervalMils: Long = 1000): OnClickListener{ private val TAG = this.javaClass.name private var mLastClickTime = 0L override fun onClick(p0: View?) { Logger.logger(TAG, "onClick") val ct = TimeUtil.getTimestamp(true) if(ct - mLastClickTime > intervalMils){ mLastClickTime = ct onSingleClick(p0) } } open fun onSingleClick(v: View?){} }
调用
getView<View>(R.id.abc).setOnClickListener(object : SingleClickListener(5000) { override fun onSingleClick(v: View?) { //TODO } })