|
@@ -1,20 +1,27 @@
|
|
|
package com.yingyang.healthconsultation.adapter
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
import android.graphics.Color
|
|
|
-import android.text.Html
|
|
|
import android.text.SpannableString
|
|
|
import android.text.Spanned
|
|
|
import android.text.style.ForegroundColorSpan
|
|
|
+import android.view.MotionEvent
|
|
|
import com.yingyang.healthconsultation.R
|
|
|
import com.yingyang.healthconsultation.databinding.ItemRecommendDoctorBinding
|
|
|
import com.yingyang.healthconsultation.entity.ConsultationBean
|
|
|
import com.yingyangfly.baselib.adapter.BaseDataBindingAdapter
|
|
|
+import com.yingyangfly.baselib.ext.getEndAnimation
|
|
|
+import com.yingyangfly.baselib.ext.getScaleAnimation
|
|
|
|
|
|
/**
|
|
|
* 推荐医生adapter
|
|
|
*/
|
|
|
class RecommendDoctorAdapter(override val layoutId: Int = R.layout.item_recommend_doctor) :
|
|
|
BaseDataBindingAdapter<ConsultationBean, ItemRecommendDoctorBinding>() {
|
|
|
+
|
|
|
+ var onClickListener: ((bean: ConsultationBean) -> Unit)? = null
|
|
|
+
|
|
|
+ @SuppressLint("ClickableViewAccessibility")
|
|
|
override fun onBindViewHolder(
|
|
|
binding: ItemRecommendDoctorBinding,
|
|
|
item: ConsultationBean,
|
|
@@ -36,5 +43,28 @@ class RecommendDoctorAdapter(override val layoutId: Int = R.layout.item_recommen
|
|
|
3, spannableString.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
|
)
|
|
|
binding.tvConsult.text = spannableString
|
|
|
+
|
|
|
+ binding.btnConsultation.setOnTouchListener { v, event ->
|
|
|
+ when (event.action) {
|
|
|
+ MotionEvent.ACTION_DOWN -> {
|
|
|
+ if (v.id == R.id.btnConsultation) {
|
|
|
+ v.startAnimation(getScaleAnimation())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MotionEvent.ACTION_UP -> {
|
|
|
+ if (v.id == R.id.btnConsultation) {
|
|
|
+ v.startAnimation(getEndAnimation())
|
|
|
+ onClickListener?.invoke(item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MotionEvent.ACTION_CANCEL -> {
|
|
|
+ if (v.id == R.id.btnConsultation) {
|
|
|
+ v.startAnimation(getEndAnimation())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ true
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|