Commit 74e60255 by 刘鹏

feat : 系统消息完成

parent df5a43dd
......@@ -11,7 +11,7 @@ ext {
"m-user" : "0.0.61.90",
"m-user-medical" : "0.0.61.99",
"m-home" : "0.0.22.70",
"m-im-medical" : "0.0.20.94",
"m-im-medical" : "0.0.21.13",
"m-im" : "0.0.20.76",
"m-dynamic" : "0.0.7.28",
"m-article" : "0.0.0.10",
......@@ -97,7 +97,7 @@ ext {
"m-user" : "0.0.61.90",
"m-user-medical" : "0.0.61.99",
"m-home" : "0.0.22.70",
"m-im-medical" : "0.0.20.94",
"m-im-medical" : "0.0.21.13",
"m-im" : "0.0.20.76",
"m-dynamic" : "0.0.7.28",
"m-article" : "0.0.0.8",
......
......@@ -9,7 +9,6 @@ import android.widget.FrameLayout
import androidx.core.content.ContextCompat
import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydlcommon.utils.URLUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.yidianling.common.tools.RxImageTool
import com.yidianling.home.R
import com.yidianling.home.constants.HomeBIConstants
......@@ -124,7 +123,6 @@ class HomeConsultItemView(private var mContext: Context, private var homeEvent:
tv_consult_chat.setOnClickListener {
homeEvent!!.consultChatClick(bodyBean.uid.toString())
ActionCountUtils.count(HomeBIConstants.YDL_PRIVATE_CHAT_CLICK)
}
}
}
......@@ -104,7 +104,6 @@ dependencies {
implementation modularPublication('com.ydl:m-confide-api')
}else {
//发布时使用
compileOnly rootProject.ext.dependencies["ydl-medical-pay"]
compileOnly rootProject.ext.dependencies["ydl-m-im-api"]
compileOnly rootProject.ext.dependencies["ydl-m-user-api"]
......
......@@ -3,14 +3,20 @@ package com.yidianling.im.http
import com.ydl.ydlcommon.base.config.YDLConstants
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA_URL
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.im.api.bean.*
import com.yidianling.im.bean.*
import com.yidianling.im.api.bean.IMExpertBuild
import com.yidianling.im.api.bean.MsgDetail
import com.yidianling.im.api.bean.UpdateStatusBean
import com.yidianling.im.bean.MsgData
import com.yidianling.im.bean.MsgHome
import com.yidianling.im.bean.SystemMsgBean
import com.yidianling.im.ui.page.fragment.bean.ChatModelBean
import com.yidianling.im.ui.page.fragment.bean.InteractBean
import com.yidianling.im.ui.page.fragment.bean.NoticeItemBean
import com.yidianling.im.ui.page.fragment.bean.UnreadMessageBean
import com.yidianling.medical.im.bean.SystemUnReadRespose
import io.reactivex.Observable
import retrofit2.http.*
......@@ -73,26 +79,38 @@ interface ImApi {
//以下接口为消息改版后新加
//私聊 获取各消息未读数
@GET("chat/getNotifyCountMessage")
@Headers(YDL_DOMAIN+ YDL_DOMAIN_JAVA)
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getUnreadMessage(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<UnreadMessageBean>>
//私聊 获取私聊消息
@GET("chat/getPrivateMessageList")
@Headers(YDL_DOMAIN+ YDL_DOMAIN_JAVA)
fun getAllChatMessage(@QueryMap params: Map<String, String>) : Observable<BaseAPIResponse<ChatModelBean>>
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getAllChatMessage(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<ChatModelBean>>
//私聊 获取通知消息
@GET("chat/getNotifyMessageList")
@Headers(YDL_DOMAIN+ YDL_DOMAIN_JAVA)
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getNoticeMessage(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<List<NoticeItemBean>>>
//私聊 已读或清除消息
@GET("chat/allMessageReadOrDel")
@Headers(YDL_DOMAIN+ YDL_DOMAIN_JAVA)
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun clearMessage(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<Boolean>>
//私聊 获取互动消息
@GET("chat/getInteractiveMessageList")
@Headers(YDL_DOMAIN+ YDL_DOMAIN_JAVA)
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun getInteractMessage(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<InteractBean>>
//获取系统消息未读数
@GET("api/client/message/v1/unReadCount")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA_URL)
fun systemUnReadCount(): Observable<BaseAPIResponse<SystemUnReadRespose>>
//获取系统消息 全部设置已读
@GET("api/client/message/v1/readAll")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA_URL)
fun systemReadAll(): Observable<BaseAPIResponse<Any>>
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ import com.yidianling.im.api.bean.*
import com.yidianling.im.api.param.RmHistoryParam
import com.yidianling.im.api.param.RmTalkParam
import com.yidianling.im.api.param.TopMessageParam
import com.yidianling.medical.im.bean.SystemUnReadRespose
import io.reactivex.Observable
/**
......@@ -50,4 +51,8 @@ interface ImHttp {
fun getInteractMessage(param: InteractMessageParam): Observable<BaseAPIResponse<InteractBean>>
fun getUnreadMessage(param: UnreadParam): Observable<BaseAPIResponse<UnreadMessageBean>>
//系统消息
fun systemUnReadCount(): Observable<BaseAPIResponse<SystemUnReadRespose>>
//系统消息 全部设置已读
fun systemReadAll(): Observable<BaseAPIResponse<Any>>
}
\ No newline at end of file
......@@ -18,6 +18,7 @@ import com.yidianling.im.ui.page.fragment.bean.InteractBean
import com.yidianling.im.ui.page.fragment.bean.NoticeItemBean
import com.yidianling.im.ui.page.fragment.bean.UnreadMessageBean
import com.yidianling.im.ui.param.*
import com.yidianling.medical.im.bean.SystemUnReadRespose
import io.reactivex.Observable
/**
......@@ -130,6 +131,19 @@ class ImHttpImpl private constructor() : ImHttp {
.flatMap { getImJavaApi().getInteractMessage(it) }
}
/**
* 系统消息
* */
override fun systemUnReadCount(): Observable<BaseAPIResponse<SystemUnReadRespose>> {
return getImJavaApi().systemUnReadCount()
}
/**
* 系统消息 全部设置已读
* */
override fun systemReadAll(): Observable<BaseAPIResponse<Any>> {
return getImJavaApi().systemReadAll()
}
object Holder {
val INSTANCE = ImHttpImpl()
}
......
......@@ -38,7 +38,7 @@ class MsgViewHolderRecipel(adapter: BaseMultiItemFetchLoadAdapter<*, *>?) :
item?.setOnClickListener {
NewH5Activity.start(
view?.context, H5Params(
"${HttpConfig.MEDICAL_H5URL}/ct/prescription/details?recipeId=${itemBean?.fromRecipelId}&hideNavBar=1",
"${HttpConfig.MEDICAL_H5URL}/ct/prescription/details?recipeId=${itemBean?.fromRecipelId}",
"处方详情"
)
)
......
......@@ -134,14 +134,14 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
mQuestionAdapter.setOneCheckListener(object : QuestionOneCheckListener {
override fun itemClick(list: List<OptionsBean>, question: QuestionsBean) {
override fun itemClick(bean: List<OptionsBean>, question: QuestionsBean) {
var otherInput = ""
list.forEachIndexed { index, optionsBean ->
bean.forEachIndexed { _, optionsBean ->
if ("其他" == optionsBean.name) {
otherInput = et_input_problem.text.toString()
}
}
answerItemClick(list, question, otherInput)
answerItemClick(bean, question, otherInput)
hideInputAndKeyboark()
}
......@@ -184,7 +184,7 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
postion: Int
) {
var otherInput = ""
list.forEachIndexed { index, optionsBean ->
list.forEachIndexed { _, optionsBean ->
if ("其他" == optionsBean.name) {
otherInput = et_input_problem.text.toString()
}
......@@ -201,6 +201,7 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
/**添加view事件*/
@SuppressLint("ClickableViewAccessibility")
private fun addVIewListener() {
left_back_btn.setOnClickListener { finish() }
tv_skip.setOnClickListener {
......@@ -499,7 +500,7 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
/***问候语之后 灵犀第一道题*/
private fun setSecondQuestionByLx() {
val questionMultiItem2 = QuestionMultiItem()
mQuestionBean!!.questionPaper.questionChains.forEach { (k, v) ->
mQuestionBean!!.questionPaper.questionChains.forEach { (_, v) ->
if (v.head) {
// 代表第一题 ,使用questionId 去questions取到对应的提
makeType3OrType4(v, questionMultiItem2)
......@@ -630,9 +631,9 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
answerQuestionRequestBean.questionPaperId = question.questionPaperId
answerQuestionRequestBean.uid = ImIn.getUserInfo()?.uid
var answersBeanList = ArrayList<AnswersBean>()
val answersBeanList = ArrayList<AnswersBean>()
for (optionsBean in list) {
var answersBean = AnswersBean()
val answersBean = AnswersBean()
answersBean.name = optionsBean.name
answersBean.optionId = optionsBean.id
......@@ -745,7 +746,7 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ uidBean ->
if (uidBean.code == "200" && uidBean.data != 0.toLong()) {
mType70RequestList.forEachIndexed { index, answerQuestionType70RequestBean ->
mType70RequestList.forEachIndexed { index, _ ->
mType70RequestList[index].toUid = uidBean.data.toString()
}
......@@ -754,7 +755,7 @@ class CmsExamQuestionPaperActivity : BaseActivity() {
.observeOn(Schedulers.io())
.subscribe()
mType71RequestList.forEachIndexed { index, answerQuestionType71RequestBean ->
mType71RequestList.forEachIndexed { index, _ ->
mType71RequestList[index].toUid = uidBean.data.toString()
}
......
......@@ -21,7 +21,7 @@ class ChatItemBean(
var title: String = "",
var toName: String = "",
var toUid: Int = 0,
var type: Int = 0,//私聊群聊type=3
var type: Int = 0,//私聊群聊type=3 1:系统消息
var utype: Int = 0,
var timeStr: String = "",
var isBusy: Int = 1, // 1服务中 0不在服务中,但是不一定是服务过
......
......@@ -10,7 +10,10 @@ import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.Utils
import com.yidianling.im.R
......@@ -49,18 +52,53 @@ class MedicalSystemListActivity : BaseActivity(), SwipeRefreshLayout.OnRefreshLi
override fun initDataAndEvent() {
initStatus()
mEmptyView = LayoutInflater.from(this@MedicalSystemListActivity)
.inflate(R.layout.platform_list_empty_view, null, false)
iv_back.setOnClickListener { finish() }
mEmptyView = LayoutInflater.from(this@MedicalSystemListActivity).inflate(R.layout.list_empty_view, null, false)
mAdapter = MedicalSystemListAdapter()
system_list.layoutManager =
LinearLayoutManager(this@MedicalSystemListActivity, LinearLayoutManager.VERTICAL, false)
system_list.adapter = mAdapter
mAdapter.setOnItemClickListener { adapter, view, position ->
mAdapter.setOnItemClickListener { _, view, position ->
if (Utils.isFastClick()) {
//防止连击
return@setOnItemClickListener
}
val itemBean = mAdapter.data[position]
when (itemBean.bizType) {
"1" -> {
//1-问诊订单
NewH5Activity.start(
view!!.context, H5Params(
"${HttpConfig.MEDICAL_H5URL}ct/inquiry/order/details?orderId=${itemBean?.bizId}&hideNavBar=1",
null
)
)
}
"2" -> {
//2-处方单
NewH5Activity.start(
view!!.context, H5Params(
"${HttpConfig.MEDICAL_H5URL}ct/prescription/details?recipeId=${itemBean?.bizId}",
null
)
)
}
"3" -> {
// 3-药品订单
NewH5Activity.start(
view!!.context, H5Params(
"${HttpConfig.MEDICAL_H5URL}ct/drug/order/details?drugOrderId=${itemBean?.bizId}&hideNavBar=1",
null
)
)
}
}
mAdapter.data[position].read = true
mAdapter.notifyDataSetChanged()
itemBean?.msgId?.let { setSystemRead(it) }
}
mAdapter.setLoadMoreView(LoadMoreView())
mAdapter.setOnLoadMoreListener(this@MedicalSystemListActivity, system_list)
......@@ -75,6 +113,16 @@ class MedicalSystemListActivity : BaseActivity(), SwipeRefreshLayout.OnRefreshLi
}
/**
* 系统消息阅读
* */
private fun setSystemRead(msgId: Int) {
ServiceImpl.instance.systemRead(msgId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe()
}
@SuppressLint("CheckResult")
private fun getSystemList() {
ServiceImpl.instance.getSystemPageList(currPage, pageSize, null)
......@@ -84,10 +132,10 @@ class MedicalSystemListActivity : BaseActivity(), SwipeRefreshLayout.OnRefreshLi
if ("200" == response.code) {
system_swipe_refresh_layout.isRefreshing = false
var list = response.data.rows
val list = response.data.rows
if (currPage == 1) {
//第一页数据
if (list != null && list.isNotEmpty()) {
if (list.isNotEmpty()) {
if (list.size < pageSize) {
mAdapter.setNewData(list)
mAdapter.removeAllFooterView()
......@@ -100,15 +148,13 @@ class MedicalSystemListActivity : BaseActivity(), SwipeRefreshLayout.OnRefreshLi
}
} else {
mAdapter.loadMoreEnd(false)
mAdapter.setNewData(list)
var net_error = mEmptyView.findViewById<TextView>(R.id.net_error)
net_error.text = "暂无系统消息~"
mAdapter.emptyView =
mEmptyView
val netError = mEmptyView.findViewById<TextView>(R.id.im_net_error)
netError.text = "暂无系统消息~"
mAdapter.emptyView = mEmptyView
}
} else {
//非第一页数据
if (list != null && list.isEmpty()) {
if (list.isEmpty()) {
mAdapter.loadMoreEnd(false)
} else {
if (list.size < pageSize) {
......@@ -116,7 +162,6 @@ class MedicalSystemListActivity : BaseActivity(), SwipeRefreshLayout.OnRefreshLi
mAdapter.loadMoreEnd(false)
} else {
mAdapter.addData(list)
if (currPage == response.data.totalPage) {
mAdapter.loadMoreEnd(false)
} else {
......@@ -129,20 +174,17 @@ class MedicalSystemListActivity : BaseActivity(), SwipeRefreshLayout.OnRefreshLi
} else {
system_swipe_refresh_layout.isRefreshing = false
mAdapter.loadMoreFail()
mAdapter.emptyView =
mEmptyView
mAdapter.emptyView = mEmptyView
}
}, { e ->
e.printStackTrace()
system_swipe_refresh_layout.isRefreshing = false
mAdapter.loadMoreFail()
var net_error = mEmptyView.findViewById<TextView>(R.id.net_error)
var reLoad = mEmptyView.findViewById<TextView>(R.id.reLoad)
net_error.text = "网络异常,请稍后再试"
val netError = mEmptyView.findViewById<TextView>(R.id.im_net_error)
val reLoad = mEmptyView.findViewById<TextView>(R.id.im_reLoad)
netError.text = "网络异常,请稍后再试"
reLoad.visibility = View.VISIBLE
mAdapter.emptyView =
mEmptyView
mAdapter.emptyView = mEmptyView
})
}
......
package com.yidianling.medical.im
import android.annotation.SuppressLint
import android.content.Context
import android.os.Build
import android.view.View
import android.view.WindowManager
import androidx.recyclerview.widget.LinearLayoutManager
......@@ -29,7 +29,6 @@ import com.yidianling.im.ui.page.widget.ChatUnusualView
import com.yidianling.im.ui.param.ChatParam
import com.yidianling.im.ui.param.ClearMessageParam
import com.yidianling.im.ui.param.UnreadParam
import com.yidianling.medical.NotificationsUtils
import com.yidianling.medical.im.adapter.MedicalChatAdapter
import com.yidianling.medical.popwindow.MedicalChatSettingPopupWindow
import de.greenrobot.event.EventBus
......@@ -70,12 +69,10 @@ class MeidicalChatFragment : BaseFragment(), XRecyclerView.LoadingListener {
mContext = requireContext()
EventBus.getDefault().register(this)
selectModel()
setShowData()
resetPageShow()
initListData()
notifiVisible()
ll_more.setOnClickListener {
if (!ImIn.isLogin()) {
ToastUtil.toastShort("请登录后再试")
......@@ -108,11 +105,12 @@ class MeidicalChatFragment : BaseFragment(), XRecyclerView.LoadingListener {
})
chatSettingPopupWindow?.contentView!!.measure(
chatSettingPopupWindow?.contentView?.measure(
View.MeasureSpec.UNSPECIFIED,
View.MeasureSpec.UNSPECIFIED
); //这句代码必须要才能获得正确的popupwindow的宽度
)
//这句代码必须要才能获得正确的popupwindow的宽度
val popupWindowWidth = chatSettingPopupWindow?.contentView!!.measuredWidth
setWindowBg(0.4f)
chatSettingPopupWindow?.showAsDropDown(
......@@ -123,40 +121,23 @@ class MeidicalChatFragment : BaseFragment(), XRecyclerView.LoadingListener {
}
}
}
override fun onDestroy() {
super.onDestroy()
EventBus.getDefault().unregister(this)
}
/**
* 系统通知开关
* */
private fun notifiVisible() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (NotificationsUtils.isNotificationOpen(mContext)) {
top_hide.visibility = View.GONE
} else {
top_hide.visibility = View.VISIBLE
top_hide.setOnClickListener {
NotificationsUtils.getAppDetailSettingIntent(mContext)
}
close_hide.setOnClickListener {
top_hide.visibility = View.GONE
}
}
}
}
override fun initDataAndEventLazy() {
}
@SuppressLint("CheckResult")
fun getChatMessageData() {
if (ImIn.getUserInfo()?.uid != "0") {
var dis = ImHttpImpl.getInstance()
ImHttpImpl.getInstance()
.getAllChatMessage(ChatParam("${ImIn.getUserInfo()?.uid}", "${0}"))
.compose(RxUtils.applySchedulers(this))
.compose<ChatModelBean>(RxUtils.resultJavaData())
.subscribe({ it ->
.subscribe({
if (it.before.data.size != 0 || it.nomal.data.size != 0) {
setData(it)
}
......@@ -164,6 +145,7 @@ class MeidicalChatFragment : BaseFragment(), XRecyclerView.LoadingListener {
chat_recyclerview.refreshComplete()
}
}, { t ->
t.printStackTrace()
ToastUtil.toastShort("您的网络出现了问题")
chat_recyclerview?.let {
chat_recyclerview.refreshComplete()
......@@ -201,13 +183,23 @@ class MeidicalChatFragment : BaseFragment(), XRecyclerView.LoadingListener {
chatAdapter?.notifyDataSetChanged()
selectTopData()
// 全部
val item = ChatItemBean(
type = 1,
title = "暂无新消息",
timeStr = "",
unReadNum = 0
)
showData.add(item)
showData.addAll(allChatData.topData.data.sortedWith(mCompare))
showData.addAll(allChatData.nomal.data.filter { it.is_top == 0 }.sortedWith(mCompare))
if (allChatData.before.data.any { it.is_top == 0 }) {
showData.add(threeWeekItem)
showData.addAll(allChatData.before.data.filter { it.is_top == 0 }.sortedWith(mCompare))
}
systemUnReadCount()
// 重置消息未读数
MsgReceiveHelper.reQueryUnreadNumber {
......@@ -263,11 +255,37 @@ class MeidicalChatFragment : BaseFragment(), XRecyclerView.LoadingListener {
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
super.setUserVisibleHint(isVisibleToUser)
if (isVisibleToUser && getIsViewCreated()) {
notifiVisible()
systemUnReadCount()
resetPageShow()
}
}
/**
* 获取系统消息
* */
@SuppressLint("CheckResult")
private fun systemUnReadCount() {
ImHttpImpl.getInstance().systemUnReadCount()
.compose(RxUtils.applySchedulers(this))
.compose(RxUtils.resultJavaData())
.subscribe({ bean ->
if (showData.size > 0 && showData[0].type == 1) {
showData[0].title = bean.title
showData[0].timeStr = bean.createTime
showData[0].unReadNum = bean.unReadTotalCount
}
chatAdapter?.notifyDataSetChanged()
}, { t ->
t.printStackTrace()
})
ImHttpImpl.getInstance().systemReadAll()
.compose(RxUtils.applySchedulers(this))
.compose(RxUtils.resultJavaData())
.subscribe {
systemUnReadCount()
}
}
fun clearData() {
showData.clear()
chatAdapter?.notifyDataSetChanged()
......@@ -314,26 +332,13 @@ class MeidicalChatFragment : BaseFragment(), XRecyclerView.LoadingListener {
}
/**
* 选择私聊列表展示模式
*/
private fun selectModel() {
setShowData()
resetPageShow()
}
/**
* 全部已读(私聊是单独处理的)
*/
@SuppressLint("CheckResult")
fun markAllMessageRead() {
var dis = ImHttpImpl.getInstance().clearMessage(
ClearMessageParam(
"${ImIn.getUserInfo()?.uid}",
"1"
)
)
ImHttpImpl.getInstance().clearMessage(ClearMessageParam("${ImIn.getUserInfo()?.uid}", "1"))
.compose(RxUtils.applySchedulers(this))
.subscribe({ it ->
.subscribe({
if (it.data) {
//清除私聊群聊未读数
MsgReceiveHelper.markAllRead()
......@@ -343,38 +348,40 @@ class MeidicalChatFragment : BaseFragment(), XRecyclerView.LoadingListener {
ToastUtil.toastShort("标记失败")
}
}, { t ->
t.printStackTrace()
ToastUtil.toastShort("您的网络出现了问题")
})
}
/**
* 刷新当前展示的消息列表的数据,刷新顶部三个消息未读数,刷新底部消息未读数
*/
fun getMsgData() {
private fun getMsgData() {
/**
* 登录状态
*/
if (ImIn.isLogin()) {
getChatMessageData()
}
requestTopUnReadNumber()
}
/**
* 刷新顶部未读数量(接口返回成功后调用的方法中会触发事件刷新底部导航栏的角标)
*/
@SuppressLint("CheckResult")
fun requestTopUnReadNumber() {
if (ImIn.getUserInfo()?.uid != "0") {
var dis =
ImHttpImpl.getInstance().getUnreadMessage(UnreadParam("${ImIn.getUserInfo()?.uid}"))
.compose<UnreadMessageBean>(RxUtils.resultJavaData())
.compose(RxUtils.applySchedulers(this))
.subscribe({ it ->
resetTopUnReadNumber(it)
}, { t ->
ToastUtil.toastShort("您的网络出现了问题")
})
ImHttpImpl.getInstance().getUnreadMessage(UnreadParam("${ImIn.getUserInfo()?.uid}"))
.compose<UnreadMessageBean>(RxUtils.resultJavaData())
.compose(RxUtils.applySchedulers(this))
.subscribe({
resetTopUnReadNumber()
}, { t ->
t.printStackTrace()
ToastUtil.toastShort("您的网络出现了问题")
})
} else {
//退出登录情况下,全部不显示
EventBus.getDefault().post(UpdateBottomBarUnreadNumEvent(0))
......@@ -384,11 +391,9 @@ class MeidicalChatFragment : BaseFragment(), XRecyclerView.LoadingListener {
/**
* 重置顶部未读数量
*/
fun resetTopUnReadNumber(bean: UnreadMessageBean) {
private fun resetTopUnReadNumber() {
val chatUnreadNum = ImIn.getInUnreadNum()//私聊未读数移动端自己读取云信
MsgReceiveHelper.isHasUnread = chatUnreadNum > 0
// 同步底部导航栏的角标数量
EventBus.getDefault().post(
......
package com.yidianling.medical.im.adapter
import android.annotation.SuppressLint
import android.app.Dialog
import android.content.Context
import android.text.TextUtils
......@@ -26,7 +27,9 @@ import com.yidianling.im.http.ImHttpImpl
import com.yidianling.im.session.SessionHelper
import com.yidianling.im.ui.page.fragment.bean.ChatItemBean
import com.yidianling.im.ui.page.fragment.view.ChatTimeItemView
import com.yidianling.medical.im.MedicalSystemListActivity
import com.yidianling.medical.im.view.MedicalChatItemView
import com.yidianling.medical.im.view.MedicalSystemItemView
import de.greenrobot.event.EventBus
/**
......@@ -43,6 +46,7 @@ class MedicalChatAdapter(
companion object {
const val TYPE_NORMAL_ITEM = 1001 // 正常item
const val TYPE_TIME_ITEM = 1002 // 三周前item
const val TYPE_SYSTEM_ITEM = 1003 // 三周前item
}
fun setData(data: ArrayList<ChatItemBean>) {
......@@ -52,40 +56,53 @@ class MedicalChatAdapter(
}
override fun getItemViewType(position: Int): Int {
if (position < mList.size && !mList[position].isThreeItem) return TYPE_NORMAL_ITEM
if (mList[position].type == 1) {
return TYPE_SYSTEM_ITEM
}
if (position < mList.size && !mList[position].isThreeItem) {
return TYPE_NORMAL_ITEM
}
return TYPE_TIME_ITEM
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val itemBean = mList[position]
when (holder) {
is SystemItemHolder -> {
holder.view.initData(itemBean)
holder.view.setOnClickListener {
MedicalSystemListActivity.start(context)
}
}
is ChatItemHolder -> {
holder.view.initData(mList[position])
holder.view.initData(itemBean)
holder.view.setOnClickListener {
//点击去私聊
if (TextUtils.equals(mList[position].toUid.toString(), "4108805")) {
SessionHelper.startP2PSession(
context, -1, "4108805", null,
P2PCustomActionHandlerImpl("4108805", "课程小助手-壹壹", "4108805")
)
} else {
IMChatUtil.startChat(context as AppCompatActivity, mList[position])
// IMChatUtil.startCms(context as AppCompatActivity, 18, "main_xinliyisheng")
when {
TextUtils.equals(itemBean.toUid.toString(), "4108805") -> {
SessionHelper.startP2PSession(
context, -1, "4108805", null,
P2PCustomActionHandlerImpl("4108805", "课程小助手-壹壹", "4108805")
)
}
else -> {
IMChatUtil.startChat(context as AppCompatActivity, itemBean)
}
}
}
holder.view.setOnLongClickListener {
var nowBean = mList[position]
val name = java.util.ArrayList<String>()
name.add("删除")
if (nowBean.is_top == 1) {
if (itemBean.is_top == 1) {
name.add("取消置顶")
} else if (nowBean.is_top == 0) {
} else if (itemBean.is_top == 0) {
name.add("置顶该聊天")
}
val unread = MsgReceiveHelper.getUnNum(nowBean.toUid.toString())//获取未读消息数量
val unread = MsgReceiveHelper.getUnNum(itemBean.toUid.toString())//获取未读消息数量
if (unread > 0) {
name.add("标记为已读")
}
......@@ -93,22 +110,21 @@ class MedicalChatAdapter(
builder.SetOnItemClickLister(object :
ListNoCancelDialog.Builder.OnItemClickLister {
override fun onItemClick(dialog: Dialog, view: View, position1: Int) {
val tag = name[position1]
when (tag) {
when (name[position1]) {
"删除" -> {
delete(nowBean)
delete(itemBean)
dialog.dismiss()
}
"置顶该聊天" -> {
toTop(nowBean, 1)
toTop(itemBean, 1)
dialog.dismiss()
}
"取消置顶" -> {
toTop(nowBean, 0)
toTop(itemBean, 0)
dialog.dismiss()
}
"标记为已读" -> {
mark(nowBean)
mark(itemBean)
dialog.dismiss()
}
}
......@@ -123,8 +139,9 @@ class MedicalChatAdapter(
}
}
is ChatTimeItemHolder -> {
holder.view.initData(mList[position])
holder.view.initData(itemBean)
}
else -> {
}
}
......@@ -135,6 +152,9 @@ class MedicalChatAdapter(
TYPE_NORMAL_ITEM -> {
ChatItemHolder(MedicalChatItemView(context))
}
TYPE_SYSTEM_ITEM -> {
SystemItemHolder(MedicalSystemItemView(context))
}
else -> {
ChatTimeItemHolder(ChatTimeItemView(context))
}
......@@ -146,9 +166,10 @@ class MedicalChatAdapter(
return mList.size
}
@SuppressLint("CheckResult")
private fun delete(bean: ChatItemBean) {
LogHelper.getInstance().writeLogSync("删除聊天:uid = " + bean.toUid)
var dis = ImHttpImpl.getInstance().rmHistory(
ImHttpImpl.getInstance().rmHistory(
RmHistoryParam(
bean.toUid.toString(),
1
......@@ -156,7 +177,7 @@ class MedicalChatAdapter(
)
.compose(RxUtils.applySchedulers(lifecycleable))
.compose(RxUtils.resultData())
.subscribe({ o ->
.subscribe({
LogHelper.getInstance().writeLogSync("删除聊天成功:uid = " + bean.toUid)
NIMClient.getService(MsgService::class.java)
.clearChattingHistory(bean.toUid.toString(), SessionTypeEnum.P2P)
......@@ -167,12 +188,13 @@ class MedicalChatAdapter(
})
}
@SuppressLint("CheckResult")
private fun deleteItem(bean: ChatItemBean) {
var dis = ImHttpImpl.getInstance().rmTalk(RmTalkParam(bean.toUid.toString()))
ImHttpImpl.getInstance().rmTalk(RmTalkParam(bean.toUid.toString()))
.compose(RxUtils.applySchedulers(lifecycleable))
.compose(RxUtils.resultData())
.subscribe({ o ->
.subscribe({
NIMClient.getService(MsgService::class.java)
.clearUnreadCount(bean.toUid.toString(), SessionTypeEnum.P2P)
NIMClient.getService(MsgService::class.java)
......@@ -185,12 +207,13 @@ class MedicalChatAdapter(
}
@SuppressLint("CheckResult")
private fun toTop(bean: ChatItemBean, istop: Int) {
LogHelper.getInstance().writeLogSync(
"置顶聊天:uid = " + bean.toUid.toString() +
"取消置顶 = " + (istop == 0)
)
var dis = ImHttpImpl.getInstance().topMessage(
ImHttpImpl.getInstance().topMessage(
TopMessageParam(
bean.toUid.toString(),
1,
......@@ -199,13 +222,14 @@ class MedicalChatAdapter(
)
.compose(RxUtils.applySchedulers(lifecycleable))
.compose(RxUtils.resultData())
.subscribe({ o ->
.subscribe({
LogHelper.getInstance().writeLogSync(
"置顶聊天成功:uid = " + bean.toUid.toString() +
"取消置顶 = " + (istop == 0)
)
mListener?.onRefresh()
}, { t ->
}, { e ->
e.printStackTrace()
LogHelper.getInstance().writeLogSync(
"置顶聊天失败:uid = " + bean.toUid.toString() +
"取消置顶 = " + (istop == 0)
......@@ -234,13 +258,18 @@ class MedicalChatAdapter(
}
/**
* 互动列表正常item的holder
* 消息列表正常item的holder
*/
inner class ChatItemHolder(val view: MedicalChatItemView) : RecyclerView.ViewHolder(view)
/**
* 互动列表正常item的holder
* 消息列表正常item的holder
*/
inner class ChatTimeItemHolder(val view: ChatTimeItemView) : RecyclerView.ViewHolder(view)
/**
* 消息列表系统消息 item的holder
*/
inner class SystemItemHolder(val view: MedicalSystemItemView) : RecyclerView.ViewHolder(view)
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ class MedicalSystemListAdapter :
override fun convert(helper: BaseViewHolder, item: SystemItemBean) {
//时间
helper.setText(R.id.time_text, TimeUtil.getTimeStringForDate(item.createTime))
helper.setText(R.id.time_text, item.createTime)
//标题
item.title?.let { title ->
helper.setText(R.id.system_title, title)
......@@ -23,7 +23,6 @@ class MedicalSystemListAdapter :
item.content?.let { content ->
helper.setText(R.id.system_dec, content)
}
helper.setVisible(R.id.chat_message_unread_num,!item.read)
}
}
\ No newline at end of file
......@@ -5,9 +5,13 @@ package com.yidianling.medical.im.bean
* */
data class SystemItemBean(
var content: String,
var createTime: Long,
var msgId: String,
var createTime: String,
var msgId: Int,
var read: Boolean,
var readTime: String,
var title: String
var title: String,
//业务类型 1-问诊订单 2-处方单 3-药品订单 4-电子签名
var bizType: String,
//业务数据ID
var bizId: String
)
package com.yidianling.medical.im.bean
data class SystemUnReadRespose(
var bizData: String,
var createTime: String,
var msgId: String,
var title: String,
var unReadTotalCount: Int
)
package com.yidianling.medical.im.view
import android.content.Context
import android.view.View
import android.widget.LinearLayout
import com.ydl.ydl_image.module.GlideApp
import com.yidianling.avchatkit.common.util.TimeUtil
import com.yidianling.im.R
import com.yidianling.im.ui.page.fragment.bean.ChatItemBean
import kotlinx.android.synthetic.main.medical_im_system_item_view.view.*
/**
* 互动列表系统消息itemView
*/
class MedicalSystemItemView(mContext: Context) : LinearLayout(mContext) {
init {
val params = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
layoutParams = params
View.inflate(mContext, R.layout.medical_im_system_item_view, this)
}
fun initData(bean: ChatItemBean?) {
bean?.let {
if (bean.timeStr.isNotEmpty()) {
chat_message_time.text = bean.timeStr
}
if (bean.title.isNotEmpty()) {
chat_message_content.text = bean.title
} else {
chat_message_content.text = "暂无新消息"
}
if (bean.unReadNum > 0) {
chat_message_unread_num.visibility = View.VISIBLE
} else {
chat_message_unread_num.visibility = View.GONE
}
}
}
}
\ No newline at end of file
......@@ -172,4 +172,9 @@ interface ServiceApi {
@Query("pageSize") pageSize: Int,
@Query("read") read: String?
): Observable<BaseAPIResponse<SystemListRespose>>
//医疗 系统消息 设为已读
@GET("api/client/message/v1/read")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA_URL)
fun systemRead(@Query("msgId") msgId: Int): Observable<BaseAPIResponse<Any>>
}
\ No newline at end of file
......@@ -283,6 +283,13 @@ class ServiceImpl private constructor() {
return YDLHttpUtils.obtainApi(ServiceApi::class.java).getSystemPageList(pageNum,pageSize,read)
}
/**
* 医疗 系统消息 设为已读
* */
fun systemRead(msgId: Int):Observable<BaseAPIResponse<Any>>{
return YDLHttpUtils.obtainApi(ServiceApi::class.java).systemRead(msgId)
}
fun uploadBatch( map :TreeMap<String, RequestBody>): Observable<BaseAPIResponse<List<MedicalFileBeanRespose>>> {
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/im_empty_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/platform_list_empty_icon"
app:layout_constraintBottom_toTopOf="@id/im_net_error"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="@+id/im_net_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="网络异常,请稍后再试"
android:textColor="#8595a9"
android:textSize="14sp"
app:layout_constraintBottom_toTopOf="@id/im_reLoad"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/im_empty_img" />
<TextView
android:id="@+id/im_reLoad"
android:layout_width="120dp"
android:layout_height="62dp"
android:background="@drawable/platform_medical_login_bg"
android:gravity="center"
android:text="重新加载"
android:textColor="@color/white"
android:textSize="14sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/im_net_error" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -53,49 +53,6 @@
</LinearLayout>
<LinearLayout
android:id="@+id/top_hide"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0d3464EC"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingRight="16dp"
android:paddingBottom="10dp">
<ImageView
android:id="@+id/close_hide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:src="@mipmap/medical_close_ovel" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="开启推送通知,及时查看消息~"
android:textColor="#ff3464ec"
android:textSize="14sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/medical_bg_3464ec_4dp_fill"
android:gravity="center"
android:paddingLeft="12dp"
android:paddingTop="5dp"
android:paddingRight="12dp"
android:paddingBottom="6dp"
android:text="立即开启"
android:textColor="#ffffffff"
android:textSize="12sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingTop="15dp"
android:paddingEnd="15dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<androidx.cardview.widget.CardView
android:id="@+id/card_img"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_marginTop="5dp"
app:cardCornerRadius="26dp"
app:cardElevation="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/chat_message_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/medical_system_item_icon" />
</androidx.cardview.widget.CardView>
<View
android:id="@+id/chat_message_unread_num"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:background="@drawable/im_chat_message_unread_num_bg"
android:gravity="center"
android:minWidth="12dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:textColor="@color/im_white"
android:visibility="gone"
app:layout_constraintRight_toRightOf="@id/card_img"
app:layout_constraintTop_toTopOf="parent"
tools:text=""
tools:visibility="visible" />
<TextView
android:id="@+id/chat_message_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:ellipsize="end"
android:maxLines="1"
android:text="系统消息"
android:textColor="@color/medical_color_0c1d31"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintLeft_toRightOf="@id/card_img"
app:layout_constraintTop_toTopOf="@id/card_img" />
<TextView
android:id="@+id/chat_message_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:maxLines="1"
android:textColor="#8595A9"
android:textSize="13sp"
app:layout_constraintBaseline_toBaselineOf="@id/chat_message_name"
app:layout_constraintRight_toRightOf="parent"
tools:text="09-04" />
<TextView
android:id="@+id/chat_message_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginRight="35dp"
android:layout_marginBottom="18dp"
android:ellipsize="end"
android:gravity="left"
android:maxLines="1"
android:text="暂无消息"
android:textColor="#495C72"
android:textSize="14sp"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="@id/chat_message_name"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/chat_message_name" />
<View
android:layout_width="0dp"
android:layout_height="0.5dp"
android:layout_marginTop="20dp"
android:background="#E7ECF0"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="@id/chat_message_name"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/chat_message_content" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
......@@ -46,6 +46,21 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/chat_message_unread_num"
android:layout_width="8dp"
android:layout_height="8dp"
android:background="@drawable/im_chat_message_unread_num_bg"
android:gravity="center"
android:minWidth="18dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:textColor="@color/im_white"
android:visibility="gone"
app:layout_constraintRight_toRightOf="@id/system_icon"
app:layout_constraintTop_toTopOf="parent"
tools:text=""
tools:visibility="visible" />
<TextView
android:id="@+id/system_title"
android:layout_width="wrap_content"
......
......@@ -6,9 +6,9 @@
android:background="@color/white">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:id="@+id/system_toolbar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_height="96dp"
android:background="@color/white"
android:elevation="0dp"
android:gravity="bottom"
......@@ -28,7 +28,7 @@
android:gravity="center"
android:maxEms="10"
android:maxLines="1"
android:text="系统消息"
android:text="@string/medical_system_message"
android:textColor="@color/medical_color_10233a"
android:textSize="18sp"
android:textStyle="bold" />
......@@ -50,7 +50,7 @@
android:layout_height="0dp"
android:background="#f6f7f9"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintTop_toBottomOf="@id/system_toolbar"
app:layout_constraintVertical_weight="1">
......
......@@ -271,5 +271,6 @@
f、用户确认从未得到服务结果会百分之百成功的许诺。<br/>
g、用户同意您的诊疗内容在去除姓名、头像、出生日期等信息后将设置为默认展示,医生给您的指导建议同时也会帮助其他相似情况的用户。<br/>
如您对本同意书有任何疑问,可联系客服进行联系。</string>
<string name="medical_system_message">系统消息</string>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment