|
@@ -1,10 +1,13 @@
|
|
|
package com.yingyangfly.mmse.adapter
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
import android.text.TextUtils
|
|
|
+import android.view.MotionEvent
|
|
|
import com.yingyang.mmse.R
|
|
|
import com.yingyang.mmse.databinding.ItemNumberBinding
|
|
|
import com.yingyangfly.baselib.adapter.BaseDataBindingAdapter
|
|
|
-import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
|
+import com.yingyangfly.baselib.ext.getEndAnimation
|
|
|
+import com.yingyangfly.baselib.ext.getScaleAnimation
|
|
|
import com.yingyangfly.baselib.ext.setTextColorResource
|
|
|
|
|
|
/**
|
|
@@ -15,6 +18,7 @@ class NumberAdapter(override val layoutId: Int = R.layout.item_number) :
|
|
|
|
|
|
var onNumClickListener: ((bean: String, type: String) -> Unit)? = null
|
|
|
|
|
|
+ @SuppressLint("ClickableViewAccessibility")
|
|
|
override fun onBindViewHolder(binding: ItemNumberBinding, item: String, position: Int) {
|
|
|
binding.data = item
|
|
|
if (TextUtils.equals("删除", item)) {
|
|
@@ -24,14 +28,26 @@ class NumberAdapter(override val layoutId: Int = R.layout.item_number) :
|
|
|
} else {
|
|
|
binding.tvNumber.setTextColorResource(R.color.color_FF222222)
|
|
|
}
|
|
|
- binding.numberLayout.setOnSingleClickListener {
|
|
|
- if (TextUtils.equals("删除", item)) {
|
|
|
- onNumClickListener?.invoke("", "1")
|
|
|
- } else if (TextUtils.equals("确定", item)) {
|
|
|
- onNumClickListener?.invoke("", "2")
|
|
|
- } else {
|
|
|
- onNumClickListener?.invoke(item, "0")
|
|
|
+ binding.numberLayout.setOnTouchListener { v, event ->
|
|
|
+ when (event.action) {
|
|
|
+ MotionEvent.ACTION_DOWN -> {
|
|
|
+ v.startAnimation(getScaleAnimation())
|
|
|
+ }
|
|
|
+ MotionEvent.ACTION_UP -> {
|
|
|
+ v.startAnimation(getEndAnimation())
|
|
|
+ if (TextUtils.equals("删除", item)) {
|
|
|
+ onNumClickListener?.invoke("", "1")
|
|
|
+ } else if (TextUtils.equals("确定", item)) {
|
|
|
+ onNumClickListener?.invoke("", "2")
|
|
|
+ } else {
|
|
|
+ onNumClickListener?.invoke(item, "0")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MotionEvent.ACTION_CANCEL -> {
|
|
|
+ v.startAnimation(getEndAnimation())
|
|
|
+ }
|
|
|
}
|
|
|
+ true
|
|
|
}
|
|
|
}
|
|
|
}
|