Commit 4ce3a7ca by 刘鹏

feat : 注销自定义消息类型,新增聊天页面,ui未更改,跳转参数未更改

parent ffef6da8
...@@ -73,6 +73,12 @@ ...@@ -73,6 +73,12 @@
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" /> android:theme="@style/platform_NoTitleTheme" />
<!--医疗聊天列表页-->
<activity
android:name=".ui.activity.MedicalChatActivity"
android:screenOrientation="portrait"
android:theme="@style/platform_NoTitleTheme" />
<!-- 云信 集成配置 --> <!-- 云信 集成配置 -->
<!-- 声明云信后台服务 --> <!-- 声明云信后台服务 -->
<service <service
......
...@@ -21,148 +21,149 @@ public class CustomAttachParser implements MsgAttachmentParser { ...@@ -21,148 +21,149 @@ public class CustomAttachParser implements MsgAttachmentParser {
JSONObject object = JSON.parseObject(json); JSONObject object = JSON.parseObject(json);
int type = object.getInteger(KEY_TYPE); int type = object.getInteger(KEY_TYPE);
JSONObject data = object.getJSONObject(KEY_DATA); JSONObject data = object.getJSONObject(KEY_DATA);
switch (type) { // switch (type) {
case CustomAttachmentType.Guess: // case CustomAttachmentType.Guess:
// attachment = new GuessAttachment(); //// attachment = new GuessAttachment();
break; // break;
// case CustomAttachmentType.SnapChat: //// case CustomAttachmentType.SnapChat:
// return new SnapChatAttachment(data); //// return new SnapChatAttachment(data);
// case CustomAttachmentType.Sticker: //// case CustomAttachmentType.Sticker:
// attachment = new StickerAttachment(); //// attachment = new StickerAttachment();
// break; //// break;
case CustomAttachmentType.RTS: // case CustomAttachmentType.RTS:
// attachment = new RTSAttachment(); //// attachment = new RTSAttachment();
break; // break;
case CustomAttachmentType.TEST: // case CustomAttachmentType.TEST:
case CustomAttachmentType.TYPE_LINGXI_TEST_QUESTION: // case CustomAttachmentType.TYPE_LINGXI_TEST_QUESTION:
attachment = new CustomAttachmentTest(); // attachment = new CustomAttachmentTest();
break; // break;
case CustomAttachmentType.EVALUATE: // case CustomAttachmentType.EVALUATE:
attachment = new CustomAttachmentEvaluate(); // attachment = new CustomAttachmentEvaluate();
break; // break;
case CustomAttachmentType.CONSULT: // case CustomAttachmentType.CONSULT:
attachment = new CustomAttachConsult(); // attachment = new CustomAttachConsult();
break; // break;
case CustomAttachmentType.ASSISTANT: // case CustomAttachmentType.ASSISTANT:
attachment = new CustomAttachmentRecommendAssistant(); // attachment = new CustomAttachmentRecommendAssistant();
break; // break;
case CustomAttachmentType.REDPACKET: // case CustomAttachmentType.REDPACKET:
attachment = new CustomAttachRedPacket(); // attachment = new CustomAttachRedPacket();
break; // break;
case CustomAttachmentType.REDSTATUS: // case CustomAttachmentType.REDSTATUS:
case CustomAttachmentType.REDTIMEOUT: // case CustomAttachmentType.REDTIMEOUT:
attachment = new CustomAttachmentRedStatus(); // attachment = new CustomAttachmentRedStatus();
break; // break;
case CustomAttachmentType.RECEIVEDMONEY: // case CustomAttachmentType.RECEIVEDMONEY:
//收款消息解析器 // //收款消息解析器
attachment = new CustomAttachReceivedMoney(); // attachment = new CustomAttachReceivedMoney();
break; // break;
case CustomAttachmentType.RECEIVEDMONEY_STATUS: // case CustomAttachmentType.RECEIVEDMONEY_STATUS:
//收款消息支付状态发生变化 // //收款消息支付状态发生变化
attachment = new CustomAttachmentReceivedSuccess(); // attachment = new CustomAttachmentReceivedSuccess();
break; // break;
case CustomAttachmentType.RECEIVEDMONEY_TIMEOUT: // case CustomAttachmentType.RECEIVEDMONEY_TIMEOUT:
//收款消息超时未支付 // //收款消息超时未支付
attachment = new CustomAttachmentReceivedTimeout(); // attachment = new CustomAttachmentReceivedTimeout();
break; // break;
case CustomAttachmentType.ADD_SUBSCRIPT_TIME: // case CustomAttachmentType.ADD_SUBSCRIPT_TIME:
//添加预约时间提醒 // //添加预约时间提醒
attachment = new CustomAttachSubScriptTime(); // attachment = new CustomAttachSubScriptTime();
break; // break;
case CustomAttachmentType.TIP_MSG: // case CustomAttachmentType.TIP_MSG:
//自定义样式提醒消息 // //自定义样式提醒消息
attachment = new CustomAttachTipMsg(); // attachment = new CustomAttachTipMsg();
break; // break;
case CustomAttachmentType.ORDER_TIP: // case CustomAttachmentType.ORDER_TIP:
//订单状态 // //订单状态
attachment = new CustomAttachmentOrderStatus(); // attachment = new CustomAttachmentOrderStatus();
break; // break;
//修改 // //修改
case CustomAttachmentType.MODIFY_TIME: // case CustomAttachmentType.MODIFY_TIME:
attachment = new CustomAttachModifyTime(); // attachment = new CustomAttachModifyTime();
break; // break;
case CustomAttachmentType.TYPE_PHONE_CALL_RED_PACKET: // case CustomAttachmentType.TYPE_PHONE_CALL_RED_PACKET:
attachment = new CustomAttachmentPhoneCallRedPacket(); // attachment = new CustomAttachmentPhoneCallRedPacket();
break; // break;
case CustomAttachmentType.TYPE_PHONE_CALL_SYSTEM_NOTICE: // case CustomAttachmentType.TYPE_PHONE_CALL_SYSTEM_NOTICE:
attachment = new CustomAttachmentPhoneCallSystemNotice(); // attachment = new CustomAttachmentPhoneCallSystemNotice();
break; // break;
case CustomAttachmentType.TYPE_CUSTOM_SYSTEM_TIPS: // case CustomAttachmentType.TYPE_CUSTOM_SYSTEM_TIPS:
attachment = new CustomSystemTips(); // attachment = new CustomSystemTips();
break; // break;
case CustomAttachmentType.TYPE_RECOMMEND_EXPORTS: // case CustomAttachmentType.TYPE_RECOMMEND_EXPORTS:
attachment = new CustomRecommendExpertListMsg(); // attachment = new CustomRecommendExpertListMsg();
break; // break;
case CustomAttachmentType.TYPE_CONSULT_SUBSCRIBE_SURE: // case CustomAttachmentType.TYPE_CONSULT_SUBSCRIBE_SURE:
//咨询预约时间确认 // //咨询预约时间确认
attachment = new CustomAttachConsultSubScript(); // attachment = new CustomAttachConsultSubScript();
break; // break;
case CustomAttachmentType.TYPE_CONSULT_PERFECT_DATA: // case CustomAttachmentType.TYPE_CONSULT_PERFECT_DATA:
//完善咨询资料消息 // //完善咨询资料消息
attachment = new CustomAttachConsultPerfectData(); // attachment = new CustomAttachConsultPerfectData();
break; // break;
case CustomAttachmentType.TYPE_PLEASE_SUBSCRIBE_CONSULT_DATE: // case CustomAttachmentType.TYPE_PLEASE_SUBSCRIBE_CONSULT_DATE:
//请预约咨询时间 // //请预约咨询时间
attachment = new CustomAttachPleaseSubscribeConsultDate(); // attachment = new CustomAttachPleaseSubscribeConsultDate();
break; // break;
case CustomAttachmentType.TYPE_CUSTOMER_SERVICE: // case CustomAttachmentType.TYPE_CUSTOMER_SERVICE:
//客服小壹名片 // //客服小壹名片
attachment = new CustomCustomerServiceCardAttachment(); // attachment = new CustomCustomerServiceCardAttachment();
break; // break;
case CustomAttachmentType.TYPE_PUSH_SHARE: // case CustomAttachmentType.TYPE_PUSH_SHARE:
//分享消息,倾诉推荐,课程,测评,文章 // //分享消息,倾诉推荐,课程,测评,文章
attachment = new CustomAttachmentShareMsg(); // attachment = new CustomAttachmentShareMsg();
break; // break;
case CustomAttachmentType.TYPE_CUSTOMER_CONSULT_CALL_STATUS: // case CustomAttachmentType.TYPE_CUSTOMER_CONSULT_CALL_STATUS:
//咨询的声网拨打状态的自定义消息 // //咨询的声网拨打状态的自定义消息
attachment = new CustomAttachConsultCallStatus(); // attachment = new CustomAttachConsultCallStatus();
break; // break;
case CustomAttachmentType.ASSISTANT_RECEIVEDMONEY: // case CustomAttachmentType.ASSISTANT_RECEIVEDMONEY:
attachment = new CustomAttachAssistantReceivedMoney(); // attachment = new CustomAttachAssistantReceivedMoney();
break; // break;
case CustomAttachmentType.TYPE_EXPERT_DETAIL_CARD: // case CustomAttachmentType.TYPE_EXPERT_DETAIL_CARD:
//专家自定义名片 // //专家自定义名片
attachment = new CustomAttachmentBusinessCard(); // attachment = new CustomAttachmentBusinessCard();
break; // break;
case CustomAttachmentType.TYPE_JUMPTO_DAOYI: // case CustomAttachmentType.TYPE_JUMPTO_DAOYI:
//跳转导医聊天界面 // //跳转导医聊天界面
attachment = new CustomAttachmentJumpToDaoYi(); // attachment = new CustomAttachmentJumpToDaoYi();
break; // break;
case CustomAttachmentType.TYPE_SWITCH_KEFU_TIPS: // case CustomAttachmentType.TYPE_SWITCH_KEFU_TIPS:
//客服转介需求 // //客服转介需求
attachment = new CustomAttachmentSwitchKeFuTips(); // attachment = new CustomAttachmentSwitchKeFuTips();
break; // break;
//41 42消息过滤掉 // //41 42消息过滤掉
case CustomAttachmentType.TYPE_FILTER_41: // case CustomAttachmentType.TYPE_FILTER_41:
case CustomAttachmentType.TYPE_FILTER_42: // case CustomAttachmentType.TYPE_FILTER_42:
case CustomAttachmentType.TYPE_FILTER_61: // case CustomAttachmentType.TYPE_FILTER_61:
case CustomAttachmentType.TYPE_FILTER_70: // case CustomAttachmentType.TYPE_FILTER_70:
case CustomAttachmentType.TYPE_FILTER_71: // case CustomAttachmentType.TYPE_FILTER_71:
case CustomAttachmentType.TYPE_FILTER_80: // case CustomAttachmentType.TYPE_FILTER_80:
attachment = new CustomAttachmentFilter(); // attachment = new CustomAttachmentFilter();
break; // break;
case CustomAttachmentType.TYPE_CONFIRM_ORDER://38 确认订单消息 // case CustomAttachmentType.TYPE_CONFIRM_ORDER://38 确认订单消息
attachment = new CustomAttachmentConfirmOrder(); // attachment = new CustomAttachmentConfirmOrder();
break; // break;
case CustomAttachmentType.TYPE_ORDER_ALREADY_DONE://39 订单已完成 // case CustomAttachmentType.TYPE_ORDER_ALREADY_DONE://39 订单已完成
attachment = new CustomAttachmentOrderAlreadyDone(); // attachment = new CustomAttachmentOrderAlreadyDone();
break; // break;
case CustomAttachmentType.TYPE_LINGXI_WHICH_QUESTION://灵犀2.0-您想要咨询下列哪些问题 // case CustomAttachmentType.TYPE_LINGXI_WHICH_QUESTION://灵犀2.0-您想要咨询下列哪些问题
attachment = new CustomAttachLingxiWhichQuestion(); // attachment = new CustomAttachLingxiWhichQuestion();
break; // break;
case CustomAttachmentType.TYPE_LINGXI_ANSWER_QUESTION://灵犀2.0-回答问题 // case CustomAttachmentType.TYPE_LINGXI_ANSWER_QUESTION://灵犀2.0-回答问题
attachment = new CustomAttachLingxiAnswerQuestion(); // attachment = new CustomAttachLingxiAnswerQuestion();
break; // break;
case CustomAttachmentType.TYPE_LINGXI_JUMP_CONFIDE_LIST: // 跳转倾诉列表 // case CustomAttachmentType.TYPE_LINGXI_JUMP_CONFIDE_LIST: // 跳转倾诉列表
attachment = new CustomAttachLingXiJumpConfideList(); // attachment = new CustomAttachLingXiJumpConfideList();
break; // break;
case CustomAttachmentType.TYPE_LINGXI_FIRST_QUESTION: //首问语 // case CustomAttachmentType.TYPE_LINGXI_FIRST_QUESTION: //首问语
attachment = new CustomAttachLingxiFirstQuestion(); // attachment = new CustomAttachLingxiFirstQuestion();
break; // break;
default: // default:
attachment = new DefaultCustomAttachment(); // attachment = new DefaultCustomAttachment();
break; // break;
} // }
attachment = new CustomAttachmentFilter();
if (attachment != null) { if (attachment != null) {
attachment.fromJson(data); attachment.fromJson(data);
......
package com.yidianling.im.ui.activity
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.jcodecraeer.xrecyclerview.CustomFooterViewCallBack
import com.jcodecraeer.xrecyclerview.XRecyclerView
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.utils.StatusBarUtils.Companion.setTransparentForImageView
import com.ydl.ydlcommon.utils.StatusBarUtils.Companion.statusBarLightMode
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.R
import com.yidianling.im.event.MessageListRefreshEvent
import com.yidianling.im.helper.MsgReceiveHelper
import com.yidianling.im.http.ImHttpImpl
import com.yidianling.im.router.ImIn
import com.yidianling.im.ui.page.fragment.adapter.ChatAdapter
import com.yidianling.im.ui.page.fragment.bean.ChatItemBean
import com.yidianling.im.ui.page.fragment.bean.ChatModelBean
import com.yidianling.im.ui.page.fragment.view.ChatFooterItemView
import com.yidianling.im.ui.page.widget.ChatUnusualView
import com.yidianling.im.ui.param.ChatParam
import de.greenrobot.event.EventBus
import kotlinx.android.synthetic.main.im_chat_fragment_layout.*
@Route(path = "/im/medical")
class MedicalChatActivity : BaseActivity(), XRecyclerView.LoadingListener {
private var chatAdapter: ChatAdapter? = null
private var allChatData: ChatModelBean = ChatModelBean() //全部数据
private var showData: ArrayList<ChatItemBean> = ArrayList() // 最终展示的数据
private val mCompare: Comparator<ChatItemBean> = Comparator { o1, o2 ->
val res = o1.timestamp.compareTo(o2.timestamp)
when {
res == 0 -> 0
res > 0 -> -1
else -> 1
}
}
override fun layoutResId(): Int {
return R.layout.medical_chat_list
}
override fun initDataAndEvent() {
initStatus()
chatAdapter = ChatAdapter(mContext, showData, this@MedicalChatActivity)
chatAdapter?.setlistener(object : ChatAdapter.ChatRecyclerViewCallback {
override fun onRefresh() {
getChatMessageData()
}
})
chat_recyclerview.layoutManager = LinearLayoutManager(this@MedicalChatActivity)
chat_recyclerview.adapter = chatAdapter
chat_recyclerview.setLoadingListener(this@MedicalChatActivity)
chat_recyclerview.setFootView(
ChatFooterItemView(mContext),
object : CustomFooterViewCallBack {
override fun onSetNoMore(p0: View?, p1: Boolean) {
}
override fun onLoadingMore(p0: View?) {
}
override fun onLoadMoreComplete(p0: View?) {
}
})
}
private fun initStatus() {
setTransparentForImageView(this@MedicalChatActivity, null)
statusBarLightMode(this@MedicalChatActivity)
}
override fun onResume() {
super.onResume()
resetPageShow()
}
fun clearData() {
showData.clear()
chatAdapter?.notifyDataSetChanged()
resetPageShow()
}
/**
* 页面展示状态逻辑
*/
private fun resetPageShow() {
ll_chat_unusual_view?.let {
if (ImIn.isLogin()) {
//登录状态
if (showData.size != 0) {
//数据不为空
chat_recyclerview.visibility = View.VISIBLE
ll_chat_unusual_view.visibility = View.GONE
} else {
chat_recyclerview.visibility = View.GONE
ll_chat_unusual_view.visibility = View.VISIBLE
ll_chat_unusual_view.setUnusualType(ChatUnusualView.TYPE_CHAT_ALL_NO_DATA)
}
} else {
//未登录状态
chat_recyclerview.visibility = View.GONE
ll_chat_unusual_view.visibility = View.VISIBLE
ll_chat_unusual_view.setUnusualType(ChatUnusualView.TYPE_UNLOGIN)
ll_chat_unusual_view.setListener(object : ChatUnusualView.ChatUnusualListener {
override fun onButtonClick() {
ImIn.loginByOneKeyLogin(mContext, true)
}
})
}
}
}
override fun onRefresh() {
EventBus.getDefault().post(MessageListRefreshEvent(0))
getChatMessageData()
}
override fun onLoadMore() {
chat_recyclerview.setNoMore(true)
}
fun getChatMessageData() {
if (ImIn.getUserInfo()?.uid != "0") {
var dis = ImHttpImpl.getInstance()
.getAllChatMessage(ChatParam("${ImIn.getUserInfo()?.uid}", "${0}"))
.compose(RxUtils.applySchedulers(this))
.compose<ChatModelBean>(RxUtils.resultJavaData())
.subscribe({ it ->
if (it.before.data.size != 0 || it.nomal.data.size != 0) {
setData(it)
}
chat_recyclerview?.let {
chat_recyclerview.refreshComplete()
}
}, { t ->
ToastUtil.toastShort("您的网络出现了问题")
chat_recyclerview?.let {
chat_recyclerview.refreshComplete()
}
})
}
}
/**
* 设置全部数据
*/
fun setData(data: ChatModelBean) {
allChatData = data
setShowData()
}
/**
* 设置最终显示得数据,(优先置顶,再最近数据,再三周前的消息item,再三周前,其余按照时间排序)
*/
private fun setShowData() {
showData.clear()
chatAdapter?.notifyDataSetChanged()
selectTopData()
// 全部
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.addAll(allChatData.before.data.filter { it.is_top == 0 }
.sortedWith(mCompare))
}
// 重置消息未读数
MsgReceiveHelper.reQueryUnreadNumber {
showData.forEachIndexed { index, _ ->
showData[index].unReadNum =
MsgReceiveHelper.getUnNum(showData[index].toUid.toString())
}
chatAdapter?.notifyDataSetChanged()
resetPageShow()
}
}
/**
* 将before数据和nomal数据里面的置顶数据筛选出来放入topData里面
*/
private fun selectTopData() {
allChatData.topData.data.clear()
allChatData.topData.data.addAll(allChatData.before.data.filter { it.is_top == 1 })
allChatData.topData.data.addAll(allChatData.nomal.data.filter { it.is_top == 1 })
}
}
\ No newline at end of file
...@@ -2,11 +2,11 @@ package com.yidianling.im.ui.page.fragment.adapter ...@@ -2,11 +2,11 @@ package com.yidianling.im.ui.page.fragment.adapter
import android.app.Dialog import android.app.Dialog
import android.content.Context import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import android.text.TextUtils import android.text.TextUtils
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import com.netease.nimlib.sdk.NIMClient import com.netease.nimlib.sdk.NIMClient
import com.netease.nimlib.sdk.msg.MsgService import com.netease.nimlib.sdk.msg.MsgService
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum
...@@ -33,7 +33,11 @@ import de.greenrobot.event.EventBus ...@@ -33,7 +33,11 @@ import de.greenrobot.event.EventBus
* 互动列表适配器 * 互动列表适配器
* Created by xj on 2019/10/14. * Created by xj on 2019/10/14.
*/ */
class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBean>,private var lifecycleable: ILifecycleable<*>): RecyclerView.Adapter<RecyclerView.ViewHolder>() { class ChatAdapter(
var context: Context,
private var mList: ArrayList<ChatItemBean>,
private var lifecycleable: ILifecycleable<*>
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
companion object { companion object {
...@@ -59,11 +63,12 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea ...@@ -59,11 +63,12 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea
holder.view.setOnClickListener { holder.view.setOnClickListener {
//点击去私聊 //点击去私聊
if (TextUtils.equals(mList[position].toUid.toString(), "4108805")) { if (TextUtils.equals(mList[position].toUid.toString(), "4108805")) {
SessionHelper.startP2PSession(context, -1, "4108805", null, SessionHelper.startP2PSession(
P2PCustomActionHandlerImpl("4108805", "课程小助手-壹壹", "4108805")) context, -1, "4108805", null,
}else { P2PCustomActionHandlerImpl("4108805", "课程小助手-壹壹", "4108805")
// IMUtil.startChat(context as AppCompatActivity, mList[position].toUid.toString(), 0, 0, null, 0, true) )
IMChatUtil.startChat(context as AppCompatActivity, mList[position]) } else {
IMChatUtil.startCms(context as AppCompatActivity, 1, null)
} }
} }
...@@ -83,7 +88,8 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea ...@@ -83,7 +88,8 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea
name.add("标记为已读") name.add("标记为已读")
} }
val builder = ListNoCancelDialog.Builder(context, name, 0) val builder = ListNoCancelDialog.Builder(context, name, 0)
builder.SetOnItemClickLister(object : ListNoCancelDialog.Builder.OnItemClickLister { builder.SetOnItemClickLister(object :
ListNoCancelDialog.Builder.OnItemClickLister {
override fun onItemClick(dialog: Dialog, view: View, position1: Int) { override fun onItemClick(dialog: Dialog, view: View, position1: Int) {
val tag = name[position1] val tag = name[position1]
when (tag) { when (tag) {
...@@ -117,7 +123,8 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea ...@@ -117,7 +123,8 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea
is ChatTimeItemHolder -> { is ChatTimeItemHolder -> {
holder.view.initData(mList[position]) holder.view.initData(mList[position])
} }
else -> {} else -> {
}
} }
} }
...@@ -139,43 +146,48 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea ...@@ -139,43 +146,48 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea
private fun delete(bean: ChatItemBean) { private fun delete(bean: ChatItemBean) {
LogHelper.getInstance().writeLogSync("删除聊天:uid = " + bean.toUid) LogHelper.getInstance().writeLogSync("删除聊天:uid = " + bean.toUid)
var dis = ImHttpImpl.getInstance().rmHistory( var dis = ImHttpImpl.getInstance().rmHistory(
RmHistoryParam( RmHistoryParam(
bean.toUid.toString(), bean.toUid.toString(),
1 1
) )
) )
.compose(RxUtils.applySchedulers(lifecycleable)) .compose(RxUtils.applySchedulers(lifecycleable))
.compose(RxUtils.resultData()) .compose(RxUtils.resultData())
.subscribe({ o -> .subscribe({ o ->
LogHelper.getInstance().writeLogSync("删除聊天成功:uid = " + bean.toUid) LogHelper.getInstance().writeLogSync("删除聊天成功:uid = " + bean.toUid)
NIMClient.getService(MsgService::class.java).clearChattingHistory(bean.toUid.toString(), SessionTypeEnum.P2P) NIMClient.getService(MsgService::class.java)
deleteItem(bean) .clearChattingHistory(bean.toUid.toString(), SessionTypeEnum.P2P)
}, {t -> deleteItem(bean)
ToastHelper.show(t.message.toString()) }, { t ->
LogHelper.getInstance().writeLogSync("删除聊天失败:uid = " + bean.toUid) ToastHelper.show(t.message.toString())
}) LogHelper.getInstance().writeLogSync("删除聊天失败:uid = " + bean.toUid)
})
} }
private fun deleteItem(bean: ChatItemBean) { private fun deleteItem(bean: ChatItemBean) {
var dis = ImHttpImpl.getInstance().rmTalk(RmTalkParam(bean.toUid.toString())) var dis = ImHttpImpl.getInstance().rmTalk(RmTalkParam(bean.toUid.toString()))
.compose(RxUtils.applySchedulers(lifecycleable)) .compose(RxUtils.applySchedulers(lifecycleable))
.compose(RxUtils.resultData()) .compose(RxUtils.resultData())
.subscribe({ o -> .subscribe({ o ->
NIMClient.getService(MsgService::class.java).clearUnreadCount(bean.toUid.toString(), SessionTypeEnum.P2P) NIMClient.getService(MsgService::class.java)
NIMClient.getService(MsgService::class.java).clearUnreadCount(bean.toUid.toString(), SessionTypeEnum.Team) .clearUnreadCount(bean.toUid.toString(), SessionTypeEnum.P2P)
MsgReceiveHelper.updateNum(bean.toUid.toString(), 0) NIMClient.getService(MsgService::class.java)
EventBus.getDefault().post(UpdateTabUnreadNumEvent()) .clearUnreadCount(bean.toUid.toString(), SessionTypeEnum.Team)
}, {t -> MsgReceiveHelper.updateNum(bean.toUid.toString(), 0)
ToastHelper.show(t.message.toString()) EventBus.getDefault().post(UpdateTabUnreadNumEvent())
}) }, { t ->
ToastHelper.show(t.message.toString())
})
} }
private fun toTop(bean: ChatItemBean, istop: Int) { private fun toTop(bean: ChatItemBean, istop: Int) {
LogHelper.getInstance().writeLogSync("置顶聊天:uid = " + bean.toUid.toString() + LogHelper.getInstance().writeLogSync(
"取消置顶 = " + (istop == 0)) "置顶聊天:uid = " + bean.toUid.toString() +
"取消置顶 = " + (istop == 0)
)
var dis = ImHttpImpl.getInstance().topMessage( var dis = ImHttpImpl.getInstance().topMessage(
TopMessageParam( TopMessageParam(
bean.toUid.toString(), bean.toUid.toString(),
...@@ -183,22 +195,27 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea ...@@ -183,22 +195,27 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea
istop istop
) )
) )
.compose(RxUtils.applySchedulers(lifecycleable)) .compose(RxUtils.applySchedulers(lifecycleable))
.compose(RxUtils.resultData()) .compose(RxUtils.resultData())
.subscribe({ o -> .subscribe({ o ->
LogHelper.getInstance().writeLogSync("置顶聊天成功:uid = " + bean.toUid.toString() + LogHelper.getInstance().writeLogSync(
"取消置顶 = " + (istop == 0)) "置顶聊天成功:uid = " + bean.toUid.toString() +
mListener?.onRefresh() "取消置顶 = " + (istop == 0)
}, {t -> )
LogHelper.getInstance().writeLogSync("置顶聊天失败:uid = " + bean.toUid.toString() + mListener?.onRefresh()
"取消置顶 = " + (istop == 0)) }, { t ->
ToastHelper.show("操作失败") LogHelper.getInstance().writeLogSync(
}) "置顶聊天失败:uid = " + bean.toUid.toString() +
"取消置顶 = " + (istop == 0)
)
ToastHelper.show("操作失败")
})
} }
private fun mark(bean: ChatItemBean) { private fun mark(bean: ChatItemBean) {
LogHelper.getInstance().writeLogSync("标记为已读:uid = " + bean.toUid.toString()) LogHelper.getInstance().writeLogSync("标记为已读:uid = " + bean.toUid.toString())
NIMClient.getService(MsgService::class.java).clearUnreadCount(bean.toUid.toString(), SessionTypeEnum.P2P) NIMClient.getService(MsgService::class.java)
.clearUnreadCount(bean.toUid.toString(), SessionTypeEnum.P2P)
MsgReceiveHelper.updateNum(bean.toUid.toString(), 0) MsgReceiveHelper.updateNum(bean.toUid.toString(), 0)
mListener?.onRefresh() mListener?.onRefresh()
EventBus.getDefault().post(UpdateTabUnreadNumEvent()) EventBus.getDefault().post(UpdateTabUnreadNumEvent())
...@@ -217,11 +234,11 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea ...@@ -217,11 +234,11 @@ class ChatAdapter(var context: Context, private var mList: ArrayList<ChatItemBea
/** /**
* 互动列表正常item的holder * 互动列表正常item的holder
*/ */
inner class ChatItemHolder(val view: ChatItemView): RecyclerView.ViewHolder(view) inner class ChatItemHolder(val view: ChatItemView) : RecyclerView.ViewHolder(view)
/** /**
* 互动列表正常item的holder * 互动列表正常item的holder
*/ */
inner class ChatTimeItemHolder(val view: ChatTimeItemView): RecyclerView.ViewHolder(view) inner class ChatTimeItemHolder(val view: ChatTimeItemView) : RecyclerView.ViewHolder(view)
} }
\ No newline at end of file
...@@ -52,9 +52,8 @@ class ChatUnusualView constructor(private val mContext: Context, attrs: Attribut ...@@ -52,9 +52,8 @@ class ChatUnusualView constructor(private val mContext: Context, attrs: Attribut
} }
// 没有私聊数据(全部) // 没有私聊数据(全部)
TYPE_CHAT_ALL_NO_DATA -> { TYPE_CHAT_ALL_NO_DATA -> {
unusual_txt.text = "主动私聊更容易遇到懂你的咨询师哦!" unusual_txt.text = "您当前还未有咨询消息哦~"
unusual_btn.text = "去咨询" unusual_btn.visibility = View.GONE
unusual_btn.visibility = View.VISIBLE
unusual_img.setImageResource(R.mipmap.im_default_siliao_none) unusual_img.setImageResource(R.mipmap.im_default_siliao_none)
} }
// 没有私聊数据(服务中) // 没有私聊数据(服务中)
......
<?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">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="96dp"
android:background="@color/white"
android:elevation="0dp"
android:gravity="bottom"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="56dp"
android:ellipsize="end"
android:gravity="center"
android:maxEms="10"
android:maxLines="1"
android:text="私聊"
android:textColor="#10233a"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/iv_back"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:paddingStart="16dp"
android:paddingEnd="20dp"
android:src="@drawable/platform_common_back" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
<RelativeLayout
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintVertical_weight="1">
<com.jcodecraeer.xrecyclerview.XRecyclerView
android:id="@+id/chat_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/im_white"></com.jcodecraeer.xrecyclerview.XRecyclerView>
<com.yidianling.im.ui.page.widget.ChatUnusualView
android:id="@+id/ll_chat_unusual_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/im_white"
android:visibility="gone" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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