Kaynağa Gözat

1.添加推荐医生列表接口

王鹏鹏 2 yıl önce
ebeveyn
işleme
47c31c7905

+ 3 - 1
healthconsultation/src/main/java/com/yingyang/healthconsultation/activity/HealthConsultationActivity.kt

@@ -39,9 +39,11 @@ class HealthConsultationActivity :
         binding {
             rvProgress.adapter = consultationAdapter
             consultationAdapter.setData(consultationBeans)
-
             rvRecommended.adapter = recommendDoctorAdapter
             recommendDoctorAdapter.setData(doctorBeans)
+            recommendDoctorAdapter.onClickListener = {
+
+            }
         }
     }
 

+ 31 - 1
healthconsultation/src/main/java/com/yingyang/healthconsultation/adapter/RecommendDoctorAdapter.kt

@@ -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
+        }
+
     }
 }

+ 1 - 0
healthconsultation/src/main/res/layout/item_recommend_doctor.xml

@@ -91,6 +91,7 @@
             tools:text="@string/app_name" />
 
         <androidx.appcompat.widget.AppCompatButton
+            android:id="@+id/btnConsultation"
             android:layout_width="@dimen/divider_160px"
             android:layout_height="@dimen/divider_48px"
             android:layout_marginTop="@dimen/divider_77px"