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 } })
标签:val,重复,private,onSingleClick,点击,mLastClickTime,android,View,ct From: https://www.cnblogs.com/ice5/p/17595336.html