|
|
@@ -17,6 +17,7 @@ import com.yingyang.healthconsultation.adapter.RecommendDoctorAdapter
|
|
|
import com.yingyang.healthconsultation.databinding.ActivityHealthConsultationBinding
|
|
|
import com.yingyangfly.baselib.bean.def.PermissionList
|
|
|
import com.yingyangfly.baselib.config.AccountConfig
|
|
|
+import com.yingyangfly.baselib.db.DepartmentBean
|
|
|
import com.yingyangfly.baselib.db.DoctorBean
|
|
|
import com.yingyangfly.baselib.ext.*
|
|
|
import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
|
|
|
@@ -49,6 +50,11 @@ class HealthConsultationActivity :
|
|
|
private val consultationAdapter by lazy { ConsultationAdapter() }
|
|
|
private val consultationBeans = mutableListOf<DoctorBean>()
|
|
|
|
|
|
+ /**
|
|
|
+ * 科室列表
|
|
|
+ */
|
|
|
+ private var departmentBeans = mutableListOf<DepartmentBean>()
|
|
|
+
|
|
|
override fun initViews() {
|
|
|
binding {
|
|
|
rvProgress.adapter = consultationAdapter
|
|
|
@@ -68,16 +74,12 @@ class HealthConsultationActivity :
|
|
|
"您有正在医疗咨询中,结束问诊后才能购买".toast()
|
|
|
} else {
|
|
|
JumpUtil.jumpActivityWithUrl(
|
|
|
- RouterUrlCommon.consultationRequest,
|
|
|
- bean.id,
|
|
|
- mContext
|
|
|
+ RouterUrlCommon.consultationRequest, bean.id, mContext
|
|
|
)
|
|
|
}
|
|
|
} else {
|
|
|
JumpUtil.jumpActivityWithUrl(
|
|
|
- RouterUrlCommon.doctorDetails,
|
|
|
- bean.id,
|
|
|
- mContext
|
|
|
+ RouterUrlCommon.doctorDetails, bean.id, mContext
|
|
|
)
|
|
|
}
|
|
|
|
|
|
@@ -106,6 +108,7 @@ class HealthConsultationActivity :
|
|
|
v.startAnimation(getScaleAnimation())
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
MotionEvent.ACTION_UP -> {
|
|
|
v.startAnimation(getEndAnimation())
|
|
|
when (v.id) {
|
|
|
@@ -113,17 +116,19 @@ class HealthConsultationActivity :
|
|
|
//返回首页
|
|
|
finish()
|
|
|
}
|
|
|
+
|
|
|
R.id.searchLayout -> {
|
|
|
JumpUtil.jumpActivity(RouterUrlCommon.searchDoctor, mContext)
|
|
|
}
|
|
|
+
|
|
|
R.id.btnConsultationRecord -> {
|
|
|
JumpUtil.jumpActivity(
|
|
|
- RouterUrlCommon.consultationRecord,
|
|
|
- mContext
|
|
|
+ RouterUrlCommon.consultationRecord, mContext
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
MotionEvent.ACTION_CANCEL -> {
|
|
|
if (v.id == R.id.layoutHome || v.id == R.id.searchLayout || v.id == R.id.btnConsultationRecord) {
|
|
|
v.startAnimation(getEndAnimation())
|
|
|
@@ -135,6 +140,13 @@ class HealthConsultationActivity :
|
|
|
|
|
|
override fun onResume() {
|
|
|
super.onResume()
|
|
|
+ departmentBeans.clear()
|
|
|
+ if (departmentDao != null) {
|
|
|
+ val departmentBeanList = departmentDao?.getAllDepartmentBean()
|
|
|
+ if (departmentBeanList.isNullOrEmpty().not()) {
|
|
|
+ departmentBeans.addAll(departmentBeanList!!)
|
|
|
+ }
|
|
|
+ }
|
|
|
getConsultationList()
|
|
|
getRecommendDoctorList()
|
|
|
}
|
|
|
@@ -153,6 +165,13 @@ class HealthConsultationActivity :
|
|
|
consultationStatus = it.status
|
|
|
consultationAdapter.setTime(it.createTime)
|
|
|
if (it.doctor != null) {
|
|
|
+ if (departmentDao != null) {
|
|
|
+ val departmentBean =
|
|
|
+ departmentDao?.getDepartmentById(it.doctor.departmentName)
|
|
|
+ if (departmentBean != null) {
|
|
|
+ it.doctor.departmentName = departmentBean.departmentName
|
|
|
+ }
|
|
|
+ }
|
|
|
consultationBeans.add(it.doctor)
|
|
|
}
|
|
|
}
|
|
|
@@ -176,15 +195,25 @@ class HealthConsultationActivity :
|
|
|
viewModel.getRecommendDoctorList(fail = {
|
|
|
"获取推荐医生列表失败".toast()
|
|
|
}, success = {
|
|
|
- if (it.isNullOrEmpty().not()) {
|
|
|
- doctorBeans.clear()
|
|
|
- doctorBeans.addAll(it!!)
|
|
|
- if (doctorDao != null) {
|
|
|
- doctorDao?.insertAll(doctorBeans)
|
|
|
+ runOnUiThread {
|
|
|
+ if (it.isNullOrEmpty().not()) {
|
|
|
+ doctorBeans.clear()
|
|
|
+ if (departmentDao != null) {
|
|
|
+ it?.forEach {
|
|
|
+ val departmentBean = departmentDao?.getDepartmentById(it.departmentName)
|
|
|
+ if (departmentBean != null) {
|
|
|
+ it.departmentName = departmentBean.departmentName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ doctorBeans.addAll(it!!)
|
|
|
+ if (doctorDao != null) {
|
|
|
+ doctorDao?.insertAll(doctorBeans)
|
|
|
+ }
|
|
|
}
|
|
|
+ recommendDoctorAdapter.showEmptyView = doctorBeans.isEmpty()
|
|
|
+ recommendDoctorAdapter.setData(doctorBeans)
|
|
|
}
|
|
|
- recommendDoctorAdapter.showEmptyView = doctorBeans.isEmpty()
|
|
|
- recommendDoctorAdapter.setData(doctorBeans)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -207,26 +236,29 @@ class HealthConsultationActivity :
|
|
|
* 登录IM
|
|
|
*/
|
|
|
private fun loginIM(sign: String, bean: DoctorBean) {
|
|
|
- TUILogin.login(mContext, AccountConfig.TENCENT_IM_APPID, User.getUserId(), sign, object :
|
|
|
- TUICallback() {
|
|
|
- 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, bean.userName)
|
|
|
- param.putString(TUIConstants.TUIChat.FACE_URL, bean.avatar)
|
|
|
- User.saveDoctorAvatar(bean.avatar)
|
|
|
- TUICore.startActivity(TUIConstants.TUIChat.C2C_CHAT_ACTIVITY_NAME, param)
|
|
|
+ TUILogin.login(mContext,
|
|
|
+ AccountConfig.TENCENT_IM_APPID,
|
|
|
+ User.getUserId(),
|
|
|
+ sign,
|
|
|
+ object : TUICallback() {
|
|
|
+ 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, bean.userName)
|
|
|
+ param.putString(TUIConstants.TUIChat.FACE_URL, bean.avatar)
|
|
|
+ User.saveDoctorAvatar(bean.avatar)
|
|
|
+ TUICore.startActivity(TUIConstants.TUIChat.C2C_CHAT_ACTIVITY_NAME, param)
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- override fun onError(errorCode: Int, errorMessage: String?) {
|
|
|
- runOnUiThread {
|
|
|
- "IM登陆失败".toast()
|
|
|
+ override fun onError(errorCode: Int, errorMessage: String?) {
|
|
|
+ runOnUiThread {
|
|
|
+ "IM登陆失败".toast()
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
/**
|