Closed leo-andr closed 3 years ago
databinding编译生成的代码有问题,暂时无法处理...
可以通过接口的方式替代高阶函数:
@BindingAdapter(value = ["noRepeatClick"])
@JvmStatic
fun setOnClick(view: View, clickListener: CustomBindClickListener?) {
val mHits = LongArray(2)
view.setOnClickListener {
System.arraycopy(mHits, 1, mHits, 0, mHits.size - 1)
mHits[mHits.size - 1] = SystemClock.uptimeMillis()
if (mHits[0] < SystemClock.uptimeMillis() - 500) {
clickListener?.onClick()
}
}
}
interface CustomBindClickListener{
fun onClick()
}
赞 :+1:
![Uploading error.png…]()