|
|
@@ -1,13 +1,17 @@
|
|
|
package com.yingyang.healthconsultation.activity
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
+import android.os.Bundle
|
|
|
import android.text.TextUtils
|
|
|
import android.view.MotionEvent
|
|
|
import android.view.View
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
import com.tencent.bugly.crashreport.CrashReport
|
|
|
import com.tencent.imsdk.v2.V2TIMCallback
|
|
|
+import com.tencent.imsdk.v2.V2TIMConversation
|
|
|
import com.tencent.imsdk.v2.V2TIMManager
|
|
|
+import com.tencent.qcloud.tuicore.TUIConstants
|
|
|
+import com.tencent.qcloud.tuicore.TUICore
|
|
|
import com.yingyang.healthconsultation.R
|
|
|
import com.yingyang.healthconsultation.adapter.ConsultationAdapter
|
|
|
import com.yingyang.healthconsultation.adapter.RecommendDoctorAdapter
|
|
|
@@ -47,7 +51,7 @@ class HealthConsultationActivity :
|
|
|
rvProgress.adapter = consultationAdapter
|
|
|
consultationAdapter.setData(consultationBeans)
|
|
|
consultationAdapter.onClickListener = {
|
|
|
- getUserSign()
|
|
|
+ getUserSign(it)
|
|
|
}
|
|
|
rvRecommended.adapter = recommendDoctorAdapter
|
|
|
recommendDoctorAdapter.setData(doctorBeans)
|
|
|
@@ -177,12 +181,14 @@ class HealthConsultationActivity :
|
|
|
/**
|
|
|
* 登录IM
|
|
|
*/
|
|
|
- private fun getUserSign() {
|
|
|
+ private fun getUserSign(bean: DoctorBean) {
|
|
|
viewModel.getUserSign(User.getUserId(), fail = {
|
|
|
it.toast()
|
|
|
}, success = {
|
|
|
it?.let {
|
|
|
- loginIM(it)
|
|
|
+ runOnUiThread {
|
|
|
+ loginIM(it, bean)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -190,15 +196,24 @@ class HealthConsultationActivity :
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
- private fun loginIM(sign: String) {
|
|
|
+ private fun loginIM(sign: String, bean: DoctorBean) {
|
|
|
V2TIMManager.getInstance().login(User.getUserId(), sign, object : V2TIMCallback {
|
|
|
override fun onError(p0: Int, p1: String?) {
|
|
|
- //用户登录IM失败
|
|
|
- CrashReport.postCatchedException(Throwable(User.getName() + "用户登录IM失败,错误码:" + p0 + " ,错误信息:" + p1))
|
|
|
+ runOnUiThread {
|
|
|
+ //用户登录IM失败
|
|
|
+ CrashReport.postCatchedException(Throwable(User.getName() + "用户登录IM失败,错误码:" + p0 + " ,错误信息:" + p1))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override fun onSuccess() {
|
|
|
-
|
|
|
+ runOnUiThread {
|
|
|
+ val param = Bundle()
|
|
|
+ param.putInt(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C)
|
|
|
+ param.putString(TUIConstants.TUIChat.CHAT_ID, bean.id)
|
|
|
+ param.putString(TUIConstants.TUIChat.CHAT_NAME, "你好")
|
|
|
+ param.putString(TUIConstants.TUIChat.FACE_URL, bean.avatar)
|
|
|
+ TUICore.startActivity(TUIConstants.TUIChat.C2C_CHAT_ACTIVITY_NAME, param)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}
|