浏览代码

1、重构聊天列表;

yzs 4 年之前
父节点
当前提交
b9040487b6

+ 204 - 0
app/src/main/java/com/shanp/youqi/app/adapter/UChatMessageListAdapter.kt

@@ -0,0 +1,204 @@
+package com.shanp.youqi.app.adapter
+
+import android.text.TextUtils
+import android.view.View
+import android.view.ViewGroup
+import android.widget.TextView
+import com.blankj.utilcode.util.TimeUtils
+import com.chad.library.adapter.base.BaseQuickAdapter
+import com.chad.library.adapter.base.BaseViewHolder
+import com.shanp.youqi.R
+import com.shanp.youqi.base.image.ImageLoader
+import com.shanp.youqi.common.vo.im.ConversationListVo
+import com.shanp.youqi.core.account.UserCore
+import com.shanp.youqi.core.database.AppDatabaseUtils
+import com.shanp.youqi.core.database.im.dao.ConversationUserInfoDao
+import com.shanp.youqi.core.database.im.entity.ConversationUserInfo
+import com.shanp.youqi.core.memory.AppManager
+import com.shanp.youqi.im.adapter.MessageListAdapter
+import com.shanp.youqi.im.util.IMUserInfoUtils
+import io.reactivex.disposables.Disposable
+import io.reactivex.internal.disposables.ListCompositeDisposable
+import io.rong.imlib.RongIMClient
+import io.rong.imlib.model.Conversation
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import me.jessyan.autosize.utils.AutoSizeUtils
+import java.text.SimpleDateFormat
+
+/**
+ * yzs
+ * 11/27/20.
+ * 消息列表
+ */
+class UChatMessageListAdapter(data: List<ConversationListVo>?)
+    : BaseQuickAdapter<ConversationListVo, BaseViewHolder>(R.layout.main_item_msg_list_layout, data) {
+
+    private val WIDTH_16: Int by lazy { AutoSizeUtils.dp2px(mContext, 16f) }
+    private val WIDTH_26: Int by lazy { AutoSizeUtils.dp2px(mContext, 26f) }
+    private val WIDTH_35: Int by lazy { AutoSizeUtils.dp2px(mContext, 35f) }
+    private val WIDTH_5: Int by lazy { AutoSizeUtils.dp2px(mContext, 5f) }
+    private val sdf: SimpleDateFormat by lazy { TimeUtils.getSafeDateFormat("yyyy-MM-dd") }
+
+    private val mTasks: ListCompositeDisposable by lazy { ListCompositeDisposable() }
+    private val mUserInfoDao: ConversationUserInfoDao? by lazy { AppDatabaseUtils.get().db().userInfoDao() }
+
+    override fun convertPayloads(helper: BaseViewHolder, vo: ConversationListVo, payloads: List<Any>) {
+        super.convertPayloads(helper, vo, payloads)
+        for (payload in payloads) {
+            val i = payload as Int
+            when (i) {
+                111 -> { // 在线状态
+                    helper.setBackgroundRes(R.id.v_im_conversation_online_state,
+                            if (vo.isOnline) R.drawable.im_ic_online_icon else R.drawable.im_ic_un_online_icon)
+                }
+                222 -> { // 互相喜欢
+                    var isShowEachFlag = false
+                    vo.chat?.let { isShowEachFlag = it.isEachLike }
+                    helper.setGone(R.id.v_each_like_flag, isShowEachFlag)
+                }
+                333 -> { // 未读消息数
+                    val count = vo.conversation.unreadMessageCount
+                    val tvCount = helper.getView<TextView>(R.id.tv_item_msg_count)
+                    setUnreadCount(count, vo.conversation, tvCount)
+                }
+                444 -> { // 刷新了弹窗列表,更新常驻页面消息未读消息数
+                    val tvCount = helper.getView<TextView>(R.id.tv_item_msg_count)
+                    getUnReadCount(vo.conversation, tvCount)
+                }
+            }
+        }
+    }
+
+    override fun convert(helper: BaseViewHolder, vo: ConversationListVo) {
+        var isShowEachFlag = false
+        vo.chat?.let { isShowEachFlag = it.isEachLike }
+
+        val conversation = vo.conversation
+        val targetId = conversation.targetId
+        val lastMessage = MessageListAdapter.checkMessageType(conversation.latestMessage, targetId)
+        helper
+                .setText(R.id.tv_item_time, TimeUtils.millis2String(conversation.sentTime, sdf))
+                .setText(R.id.tv_item_last_msg, lastMessage)
+                .setGone(R.id.v_each_like_flag, isShowEachFlag)
+                .setBackgroundRes(R.id.v_im_conversation_online_state,
+                        if (vo.isOnline) R.drawable.im_ic_online_icon else R.drawable.im_ic_un_online_icon)
+
+        setUnReadCount(helper.getView(R.id.tv_item_msg_count), conversation.unreadMessageCount)
+
+
+        IMUserInfoUtils.get().getUserInfo(targetId)?.let {
+            setData(helper, it, conversation)
+        } ?: queryUser(helper, targetId, conversation)
+    }
+
+    private fun getUnReadCount(conversation: Conversation, tvCount: TextView) {
+        if (!AppManager.get().isConnectRongCloud) return
+        RongIMClient.getInstance().getUnreadCount(conversation.conversationType,
+                conversation.targetId, object : RongIMClient.ResultCallback<Int?>() {
+            override fun onSuccess(count: Int?) {
+                setUnreadCount(count, conversation, tvCount)
+            }
+
+            override fun onError(errorCode: RongIMClient.ErrorCode) {}
+        })
+    }
+
+    private fun setUnreadCount(count: Int?, conversation: Conversation, tvCount: TextView) {
+        if (count != null) {
+            conversation.unreadMessageCount = count
+            val num: String = if (count > 99) "99+" else "" + count
+            tvCount.text = num
+            tvCount.visibility = if (count > 0) View.VISIBLE else View.INVISIBLE
+        }
+    }
+
+    private fun setData(helper: BaseViewHolder, userInfo: ConversationUserInfo?, c: Conversation) {
+        var userName = ""
+        var headImg = ""
+        userInfo?.let {
+            userName = it.name
+            headImg = it.headImg
+            c.senderUserName = it.name
+            c.portraitUrl = it.headImg
+        }
+        if (TextUtils.isEmpty(userName)) userName = c.targetId
+
+        helper.setText(R.id.tv_item_user_name, userName)
+        ImageLoader.get().loadAvatar(headImg,
+                helper.getView(R.id.civ_item_avatar),
+                R.drawable.ic_yq_tourists_avatar,
+                R.drawable.ic_yq_tourists_avatar)
+    }
+
+    private fun queryUser(helper: BaseViewHolder, targetId: String, conversation: Conversation) {
+        if (TextUtils.isEmpty(targetId)) return
+        GlobalScope.launch(Dispatchers.Main) {
+            val userInfo = withContext(Dispatchers.IO) {
+                val info = mUserInfoDao?.getUserInfoById(targetId.toLong())
+                info?.let {
+                    IMUserInfoUtils.get().addUser(it)
+                    conversation.senderUserName = it.name
+                    conversation.portraitUrl = it.headImg
+                    mUserInfoDao?.insert(it)
+                }
+                info
+            }
+            if (userInfo != null) {
+                setData(helper, userInfo, conversation)
+            } else {
+                val conversationUserInfo = withContext(Dispatchers.IO) {
+                    val baseUserInfo = UserCore.get().baseUserInfoDoGet(targetId)
+                    var conversationUserInfo: ConversationUserInfo? = null
+                    baseUserInfo?.let {
+                        conversationUserInfo = ConversationUserInfo()
+                        conversationUserInfo!!.name = baseUserInfo.nickName
+                        conversationUserInfo!!.headImg = baseUserInfo.headImg
+                        conversationUserInfo!!.uid = targetId.toLong()
+                        IMUserInfoUtils.get().addUser(conversationUserInfo)
+                        conversation.senderUserName = it.nickName
+                        conversation.portraitUrl = it.headImg
+                        mUserInfoDao?.insert(conversationUserInfo)
+                    }
+                    conversationUserInfo
+                }
+                if (conversationUserInfo != null) {
+                    setData(helper, conversationUserInfo, conversation)
+                }
+            }
+        }
+    }
+
+    fun setUnReadCount(tvMessageCount: TextView, unreadCount: Int = 0) {
+        if (unreadCount == 0) {
+            tvMessageCount.text = "0"
+            tvMessageCount.visibility = View.INVISIBLE
+            return
+        }
+        tvMessageCount.text = unreadCount.toString()
+        tvMessageCount.visibility = View.VISIBLE
+        val length: Int = unreadCount.toString().length
+        var width = ViewGroup.LayoutParams.WRAP_CONTENT
+        when (length) {
+            1 -> width = WIDTH_16
+            2 -> width = WIDTH_26
+            3 -> width = WIDTH_35
+        }
+        val params = tvMessageCount.layoutParams
+        params.width = width
+        tvMessageCount.layoutParams = params
+        if (width == ViewGroup.LayoutParams.WRAP_CONTENT) {
+            tvMessageCount.setPadding(WIDTH_5, 0, WIDTH_5, 0)
+        }
+    }
+
+    fun release() {
+        mTasks?.dispose()
+    }
+
+    private fun hold(task: Disposable) {
+        mTasks?.add(task)
+    }
+}

+ 0 - 308
app/src/main/java/com/shanp/youqi/app/fragment/ChatMessageListFragmentKT.kt

@@ -1,308 +0,0 @@
-package com.shanp.youqi.app.fragment
-
-import android.annotation.SuppressLint
-import android.content.Intent
-import android.os.Handler
-import android.view.View
-import android.view.ViewGroup
-import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import com.blankj.utilcode.util.NetworkUtils
-import com.blankj.utilcode.util.ToastUtils
-import com.chad.library.adapter.base.BaseQuickAdapter
-import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
-import com.shanp.youqi.R
-import com.shanp.youqi.app.activity.InteractiveMessageListActivity
-import com.shanp.youqi.app.util.TopSmoothScroller
-import com.shanp.youqi.base.rx.EventSubscriber
-import com.shanp.youqi.base.rx.RxBus
-import com.shanp.youqi.common.app.Route.ARouterFun
-import com.shanp.youqi.common.base.UChatFragment
-import com.shanp.youqi.common.ui.dialog.CustomDelDialog
-import com.shanp.youqi.common.utils.NotificationHelper
-import com.shanp.youqi.common.vo.im.ConversationListVo
-import com.shanp.youqi.core.config.C
-import com.shanp.youqi.core.event.IMReceivedMessageEvent
-import com.shanp.youqi.core.event.IMSendMessageEvent
-import com.shanp.youqi.core.im.Constant
-import com.shanp.youqi.core.main.IMainClent
-import com.shanp.youqi.core.memory.AppManager
-import com.shanp.youqi.databinding.ImItemMessageHeaderBinding
-import com.shanp.youqi.databinding.MainFragmentUqchatMsgBinding
-import com.shanp.youqi.im.activity.UChatConversationActivity
-import com.shanp.youqi.im.adapter.MessageListAdapter
-import com.shanp.youqi.im.util.IMChatUtils
-import io.rong.imlib.RongIMClient
-import io.rong.imlib.model.Conversation
-import io.rong.imlib.model.Message
-
-
-/**
- * yzs
- * 9/11/20.
- */
-class ChatMessageListFragmentKT : UChatFragment(), View.OnClickListener {
-    private lateinit var binding: MainFragmentUqchatMsgBinding
-    private lateinit var headerBinding: ImItemMessageHeaderBinding
-
-    private lateinit var recyclerView: RecyclerView
-
-
-    private val timeStamp: Long = 0 // 最后一条消息的时间戳
-
-    private val count: Int = 10 // 每页获取的条数
-
-    private var mMainClent: IMainClent? = null
-    private var mHelper: NotificationHelper? = null
-    private lateinit var mTopSmoothScroller: TopSmoothScroller
-    private lateinit var mManager: LinearLayoutManager
-    private val mDelDialog = CustomDelDialog()
-
-    private var mSystemConversation: ConversationListVo = ConversationListVo(null, false)
-    private var mConversationList = mutableListOf<ConversationListVo>()
-
-    private val mAdapter = MessageListAdapter(mConversationList)
-    private val mMessageListInitialize = false
-    private var mReceivedMessageLock = false
-    private var mHandlerMessageLock = false
-    private val mReceivedMessageList = mutableListOf<Message>()
-
-    var mMessageHandler: Handler = @SuppressLint("HandlerLeak")
-    object : Handler() {
-        override fun handleMessage(msg: android.os.Message) {
-            if (msg.what != 1) return
-            if (mReceivedMessageList.size > 0) {
-                if (mHandlerMessageLock) {
-                    sendEmptyMessage(1)
-                    return
-                }
-                mHandlerMessageLock = true
-                val message = mReceivedMessageList[0]
-                mReceivedMessageList.remove(message)
-                disposalReadMessage(message)
-                sendEmptyMessage(1)
-            } else {
-                mHandlerMessageLock = false
-                mReceivedMessageLock = false
-            }
-        }
-    }
-
-    override fun initEventAndData(view: View) {
-        binding = MainFragmentUqchatMsgBinding.bind(view)
-        ARouterFun.startAttestAc(-1)
-    }
-
-    override fun getLayoutId() = R.layout.main_fragment_uqchat_msg
-
-    override fun onClick(v: View) {
-        if (v == headerBinding.tvOpenNotify) {
-            mHelper?.let {
-                if (!it.isNotificationEnabled) {
-                    it.openNotificationSetting()
-                } else {
-                    if (!it.isOpenChannel(NotificationHelper.YQ_CHAT_CHANNEL)) {
-                        it.openChannelSetting(NotificationHelper.YQ_CHAT_CHANNEL)
-                    }
-                }
-            }
-        } else {
-            if (!AppManager.get().isLogin) {
-                ARouterFun.startOneKeyLogin()
-                return
-            }
-            if (!NetworkUtils.isConnected()) {
-                ToastUtils.showShort("网络异常,请稍后重试")
-                return
-            }
-            val userMine = AppManager.get().userMine
-            if (userMine == null) {
-                ARouterFun.startOneKeyLogin()
-                return
-            }
-            when (v) {
-                binding.civAvatar -> {
-                    ARouterFun.startUserMe()
-                }
-                headerBinding.rlPraiseSelfLayout -> {
-                    startActivity(Intent(mContext, InteractiveMessageListActivity::class.java))
-                }
-                headerBinding.rlOrderMessageLayout -> {
-                    ARouterFun.startPlayOrderList(1)
-                }
-                headerBinding.civLiveUser, headerBinding.tvLiveUser -> {
-                    ARouterFun.startUserLike(1)
-                }
-                headerBinding.civEachLike, headerBinding.tvEachLike -> {
-                    ARouterFun.startUserLike(2)
-                }
-                headerBinding.civLikeMe, headerBinding.tvLikeMe -> {
-                }
-                headerBinding.civVisitor, headerBinding.tvVisitor -> {
-                }
-            }
-        }
-    }
-
-
-    private fun rongImIsConnect(): Boolean {
-        return AppManager.get().isConnectRongCloud
-    }
-
-    private fun startConversation(c: Conversation, position: Int) {
-        c.unreadMessageCount = 0
-        notifyItemChanged(position, 333)
-        clearMessagesUnreadStatus(c.conversationType, c.targetId)
-        UChatConversationActivity.launch(
-                mContext,
-                c.conversationType,
-                c.targetId,
-                c.senderUserName,
-                c.portraitUrl,
-                Constant.conversation.ENTRY_TYPE_DEFAULT
-        )
-    }
-
-    private fun clearMessagesUnreadStatus(conversationType: Conversation.ConversationType, targetId: String) {
-        RongIMClient.getInstance().clearMessagesUnreadStatus(conversationType, targetId, object : RongIMClient.ResultCallback<Boolean>() {
-            override fun onSuccess(b: Boolean?) {
-                mMainClent?.refreshUnreadNumber()
-            }
-
-            override fun onError(errorCode: RongIMClient.ErrorCode?) {
-                mMainClent?.refreshUnreadNumber()
-            }
-        })
-    }
-
-    private fun notifyItemChanged(position: Int, payload: Any) {
-        mAdapter.notifyItemChanged(position, payload)
-    }
-
-    private fun showAgainDeleteConversationDialog(item: Conversation, position: Int) {
-
-        mDelDialog.setIsSelf(true)
-        mDelDialog.setListener { isDel, _ ->
-            if (isDel) {
-                removeConversation(item)
-                mAdapter.remove(position)
-            }
-        }
-        if (mDelDialog.isVisible) return
-        mDelDialog.show(childFragmentManager)
-    }
-
-    /**
-     * 单独获取系统类型会话
-     */
-    private fun getSystemConversation(callback: RongIMClient.ResultCallback<Conversation>) {
-        RongIMClient.getInstance().getConversation(Conversation.ConversationType.SYSTEM,
-                C.im.ROMG_SYSTEM_NOTICE, callback)
-    }
-
-    /**
-     * 获取私聊会话
-     */
-    private fun getConversation(targetId: String, callback: RongIMClient.ResultCallback<Conversation>) {
-        RongIMClient.getInstance().getConversation(Conversation.ConversationType.PRIVATE, targetId, callback)
-    }
-
-    /**
-     * 单独获取私聊类型会话
-     */
-    private fun getPrivateConversation(callback: RongIMClient.ResultCallback<List<Conversation>>) {
-        RongIMClient.getInstance().getConversationListByPage(callback, timeStamp, count, Conversation.ConversationType.PRIVATE)
-    }
-
-
-    /**
-     * 移除会话
-     */
-    private fun removeConversation(item: Conversation?) {
-        if (item == null) return
-        IMChatUtils.removeConversation(item.conversationType, item.targetId, object : RongIMClient.ResultCallback<Boolean>() {
-            override fun onSuccess(b: Boolean) {
-                if (b) IMChatUtils.clearMessage(item.conversationType, item.targetId, null)
-            }
-
-            override fun onError(errorCode: RongIMClient.ErrorCode) {}
-        })
-    }
-
-
-    /**
-     * 处理消息
-     */
-    private fun disposalReadMessage(m: Message) {
-        val targetId = m.targetId
-        val type = m.conversationType
-        if (type == Conversation.ConversationType.SYSTEM) {
-            systemType(targetId)
-        } else if (type == Conversation.ConversationType.PRIVATE) {
-            privateType(targetId)
-        }
-    }
-
-    private fun systemType(targetId: String) {
-        if (targetId != C.im.ROMG_SYSTEM_NOTICE) return
-        getSystemConversation(object : RongIMClient.ResultCallback<Conversation>() {
-            override fun onSuccess(conversation: Conversation?) {
-                conversation?.let {
-                    mSystemConversation.conversation = conversation
-                    val currentSystemChat = mConversationList.firstOrNull {
-                        it.conversation.targetId == C.im.ROMG_SYSTEM_NOTICE
-                    }
-                    currentSystemChat?.let {
-                        mConversationList.remove(currentSystemChat)
-                    }
-                    mConversationList.add(0, mSystemConversation)
-                    mAdapter.notifyDataSetChanged()
-                } ?: clearMessagesUnreadStatus(Conversation.ConversationType.SYSTEM, targetId)
-                mHandlerMessageLock = false
-            }
-
-            override fun onError(errorCode: RongIMClient.ErrorCode?) {
-                mHandlerMessageLock = false
-            }
-        })
-    }
-
-    private fun privateType(targetId: String) {
-        getConversation(targetId, object : RongIMClient.ResultCallback<Conversation>() {
-            override fun onSuccess(conversation: Conversation?) {
-                conversation?.let {
-                    val currentPrivateChat = mConversationList.firstOrNull {
-                        it.conversation.targetId == targetId
-                    }
-                    currentPrivateChat?.let {
-                        mConversationList.remove(currentPrivateChat)
-                    }
-                    val currentSystemChat = mConversationList.firstOrNull {
-                        it.conversation.targetId == C.im.ROMG_SYSTEM_NOTICE
-                    }
-
-                    var insertIndex = 1 // 插入的 index
-
-                    if (currentSystemChat == null && mSystemConversation.conversation != null) {
-                        mConversationList.add(0, mSystemConversation)
-                    } else {
-                        insertIndex = 0
-                    }
-
-                    val vo = ConversationListVo(conversation, true)
-                    mConversationList.add(insertIndex, vo)
-                    mAdapter.notifyDataSetChanged()
-//                    if (indexFlag >= 0) {
-//                        checkUserInfoOne(conversation.targetId)
-//                    }
-                }
-                mHandlerMessageLock = false
-            }
-
-            override fun onError(errorCode: RongIMClient.ErrorCode?) {
-            }
-
-        })
-    }
-
-}

+ 526 - 0
app/src/main/java/com/shanp/youqi/app/fragment/ChatMessageListFragmentKotlin.kt

@@ -0,0 +1,526 @@
+package com.shanp.youqi.app.fragment
+
+import android.content.Intent
+import android.text.TextUtils
+import android.view.View
+import android.view.ViewGroup
+import androidx.recyclerview.widget.LinearLayoutManager
+import androidx.recyclerview.widget.RecyclerView
+import com.blankj.utilcode.util.ActivityUtils
+import com.blankj.utilcode.util.ClickUtils
+import com.blankj.utilcode.util.TimeUtils
+import com.chad.library.adapter.base.BaseQuickAdapter
+import com.shanp.youqi.R
+import com.shanp.youqi.app.activity.InteractiveMessageListActivity
+import com.shanp.youqi.app.adapter.UChatMessageListAdapter
+import com.shanp.youqi.base.image.ImageLoader
+import com.shanp.youqi.base.rx.EventSubscriber
+import com.shanp.youqi.base.rx.RxBus
+import com.shanp.youqi.base.view.CoreCallback
+import com.shanp.youqi.common.app.Route.ARouterFun
+import com.shanp.youqi.common.base.UChatFragment
+import com.shanp.youqi.common.ui.dialog.CustomDelDialog
+import com.shanp.youqi.common.ui.dialog.PrivilegeDialog
+import com.shanp.youqi.common.utils.*
+import com.shanp.youqi.common.utils.AppPermissionClickUtils.checkPrivateChat
+import com.shanp.youqi.common.vo.im.ConversationListVo
+import com.shanp.youqi.core.config.C
+import com.shanp.youqi.core.event.IMConnectSuccessEvent
+import com.shanp.youqi.core.event.IMReceivedMessageEvent
+import com.shanp.youqi.core.event.IMSendMessageEvent
+import com.shanp.youqi.core.im.Constant
+import com.shanp.youqi.core.im.IMCore
+import com.shanp.youqi.core.main.IMainClent
+import com.shanp.youqi.core.memory.AppManager
+import com.shanp.youqi.core.model.IMCheckChat
+import com.shanp.youqi.core.model.IMUserOnlineState
+import com.shanp.youqi.databinding.MainFragmentUqchatMsgKotlinBinding
+import com.shanp.youqi.databinding.MainItemMessageHeaderKotlinBinding
+import com.shanp.youqi.im.activity.FindBossActivity
+import com.shanp.youqi.im.activity.UChatConversationActivity
+import com.shanp.youqi.im.util.IMChatUtils
+import io.rong.imlib.RongIMClient
+import io.rong.imlib.model.Conversation
+import io.rong.imlib.model.Message
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import java.text.SimpleDateFormat
+import java.util.*
+import kotlin.concurrent.thread
+
+/**
+ * yzs
+ * 11/27/20.
+ */
+class ChatMessageListFragmentKotlin : UChatFragment() {
+
+    var unreadCount: Int = 0
+
+    private var timeStamp = 0L
+
+    private var lastRefreshTime = 0L
+
+
+    private val sdf: SimpleDateFormat by lazy { TimeUtils.getSafeDateFormat("yyyy-MM-dd") }
+    private lateinit var binding: MainFragmentUqchatMsgKotlinBinding
+    private lateinit var headerBinding: MainItemMessageHeaderKotlinBinding
+
+    private val adapter = UChatMessageListAdapter(null)
+
+    private var mainClient: IMainClent? = null
+
+    private val mHelper: NotificationHelper by lazy { NotificationHelper(mContext) }
+
+    override fun getLayoutId(): Int = R.layout.main_fragment_uqchat_msg_kotlin
+
+    override fun initEventAndData(view: View) {
+        binding = MainFragmentUqchatMsgKotlinBinding.bind(view)
+        if (mContext.javaClass.simpleName.contains("MainActivity")) mainClient = mContext as IMainClent
+        initRecyclerView()
+        initListener()
+        getSystemConversation()
+    }
+
+    private fun initRecyclerView() {
+        val headerView = layoutInflater.inflate(R.layout.main_item_message_header_kotlin,
+                binding.rcv.parent as ViewGroup, false)
+        headerBinding = MainItemMessageHeaderKotlinBinding.bind(headerView)
+
+        binding.rcv.layoutManager = LinearLayoutManager(mContext, RecyclerView.VERTICAL, false)
+        binding.rcv.itemAnimator = null
+        binding.rcv.adapter = adapter
+
+        adapter.addHeaderView(headerView)
+
+        // 初始化 headerView
+        headerBinding.davAvatar.clearView()
+        headerBinding.rlFindTheBossLayout.visibility = View.VISIBLE
+        headerBinding.tvLikeMeNumber.visibility = View.INVISIBLE
+        headerBinding.tvVisitorNumber.visibility = View.INVISIBLE
+
+        headerBinding.civLikeMeMask.visibility = View.GONE
+        headerBinding.civVisitorMask.visibility = View.GONE
+
+        headerBinding.civLikeMe.setImageResource(R.drawable.im_ic_top_like_me)
+        headerBinding.civVisitor.setImageResource(R.drawable.im_ic_top_visitor)
+
+
+
+
+        setOnClickListener(viewOnClickListener,
+                headerBinding.clYqConversationLayout,
+                headerBinding.rlFindTheBossLayout,
+                headerBinding.rlPraiseSelfLayout,
+                headerBinding.rlOrderMessageLayout,
+                headerBinding.civLiveUser,
+                headerBinding.tvLiveUser,
+                headerBinding.civEachLike,
+                headerBinding.tvEachLike,
+                headerBinding.civLikeMe,
+                headerBinding.tvLikeMe,
+                headerBinding.civVisitor,
+                headerBinding.tvVisitor,
+                headerBinding.tvOpenNotify,
+
+                binding.civAvatar
+        )
+
+    }
+
+    private val viewOnClickListener = object : ClickUtils.OnDebouncingClickListener() {
+        override fun onDebouncingClick(v: View) {
+            if (v == headerBinding.tvOpenNotify) {
+                openNotificationSetting()
+            } else {
+                if (!AppManager.get().isLogin) {
+                    ARouterFun.startOneKeyLogin()
+                    return
+                }
+                when (v) {
+                    headerBinding.clYqConversationLayout -> startSystemConversation()
+                    headerBinding.rlFindTheBossLayout -> ActivityUtils.startActivity(FindBossActivity::class.java)
+
+                    headerBinding.rlPraiseSelfLayout -> {
+                        startActivity(Intent(mContext, InteractiveMessageListActivity::class.java))
+                        headerBinding.tvPraiseSelfNumber.visibility = View.INVISIBLE
+                    }
+
+                    headerBinding.rlOrderMessageLayout -> {
+                        ARouterFun.startPlayOrderList(1)
+                        headerBinding.tvOrderMessageNumber.text = "0"
+                        headerBinding.tvOrderMessageNumber.visibility = View.INVISIBLE
+                    }
+
+                    headerBinding.civLiveUser, headerBinding.tvLiveUser -> ARouterFun.startUserLike(1)
+
+                    headerBinding.civEachLike, headerBinding.tvEachLike -> ARouterFun.startUserLike(2)
+
+                    headerBinding.civLikeMe, headerBinding.tvLikeMe -> likeMe()
+
+                    headerBinding.civVisitor, headerBinding.tvVisitor -> visitor()
+
+                    binding.civAvatar -> {
+                        if (!AppManager.get().isLogin) ARouterFun.startOneKeyLogin() else ARouterFun.startUserMe()
+                    }
+                }
+            }
+        }
+    }
+
+    private fun openNotificationSetting() {
+        if (!mHelper.isNotificationEnabled) {
+            mHelper.openNotificationSetting()
+            return
+        }
+        if (!mHelper.isOpenChannel(NotificationHelper.YQ_CHAT_CHANNEL)) {
+            mHelper.openChannelSetting(NotificationHelper.YQ_CHAT_CHANNEL)
+        }
+    }
+
+    private fun checkNotifyEnable() {
+        var isEnabled = false
+        val enabled = mHelper.isNotificationEnabled
+        val openChannel = mHelper.isOpenChannel(NotificationHelper.YQ_CHAT_CHANNEL)
+        if (enabled && openChannel) isEnabled = true
+        headerBinding.rlOpenNotifyLayout.visibility = if (isEnabled) View.GONE else View.VISIBLE
+    }
+
+    private fun visitor() {
+        val userMine = AppManager.get().userMine
+        var playerAuthentication = userMine.playerAuthentication
+        if (playerAuthentication == null) playerAuthentication = ""
+        val isPlayer = playerAuthentication == "1"
+        if (!isPlayer && !userMine.isExplotionLight) {
+            PrivilegeDialog(mContext, C.pay.SN_EXPOLSION_LIGHT, null).show()
+        } else ARouterFun.startUserVisitor()
+    }
+
+    private fun likeMe() {
+        if (!AppManager.get().userMine.isExplotionLight) {
+            PrivilegeDialog(mContext, C.pay.SN_EXPOLSION_LIGHT, null).show()
+            return
+        }
+        ARouterFun.startUserLike(3)
+    }
+
+
+    private fun initListener() {
+        register(RxBus.get().toFlowable(IMReceivedMessageEvent::class.java), object : EventSubscriber<IMReceivedMessageEvent>() {
+            override fun onReceive(event: IMReceivedMessageEvent) {
+                if (!AppManager.get().isConnectRongCloud) return
+                event.message?.let {
+                    if (it.conversationType == Conversation.ConversationType.SYSTEM) {
+                        getSystemConversation()
+                    } else if (it.conversationType == Conversation.ConversationType.PRIVATE) {
+                        disposeMessage(it)
+                    }
+                }
+            }
+        })
+
+        register(RxBus.get().toFlowable(IMSendMessageEvent::class.java), object : EventSubscriber<IMSendMessageEvent>() {
+            override fun onReceive(event: IMSendMessageEvent) {
+                super.onReceive(event)
+                event.message?.let { disposeMessage(it) }
+            }
+        })
+
+        register(RxBus.get().toFlowable(IMConnectSuccessEvent::class.java), object : EventSubscriber<IMConnectSuccessEvent?>() {
+            override fun onReceive(e: IMConnectSuccessEvent?) {
+                super.onReceive(e)
+                getSystemConversation()
+                getPrivateConversationList()
+            }
+        })
+
+        binding.srl.setOnLoadMoreListener {
+            getPrivateConversationList()
+        }
+
+        adapter.onItemClickListener = BaseQuickAdapter.OnItemClickListener { _, _, position ->
+            adapter.getItem(position)?.conversation?.let {
+                startListConversation(it, position)
+            }
+        }
+
+        adapter.onItemLongClickListener = BaseQuickAdapter.OnItemLongClickListener { _, _, position ->
+            adapter.getItem(position)?.conversation?.let {
+                showAgainDeleteConversationDialog(it, position)
+            }
+            true
+        }
+    }
+
+    private fun showAgainDeleteConversationDialog(item: Conversation, position: Int) {
+        CustomDelDialog().setIsSelf(true)
+                .setListener { isDel: Boolean, isSelf: Boolean ->
+                    if (isDel && isSelf) {
+                        removeConversation(item)
+                        adapter.remove(position)
+                    }
+                }.show(childFragmentManager)
+    }
+
+    // 从数据库中删除会话
+    private fun removeConversation(item: Conversation) {
+        IMChatUtils.removeConversation(
+                item.conversationType,
+                item.targetId, object : RongIMClient.ResultCallback<Boolean>() {
+            override fun onSuccess(b: Boolean) {
+                if (b) IMChatUtils.clearMessage(item.conversationType, item.targetId, null)
+            }
+
+            override fun onError(errorCode: RongIMClient.ErrorCode) {}
+        })
+    }
+
+    private fun disposeMessage(message: Message) {
+        GlobalScope.launch {
+            withContext(Dispatchers.IO) {
+                disposePrivateType(message.targetId)
+            }
+        }
+    }
+
+    private fun disposePrivateType(targetId: String) {
+        RongIMClient.getInstance().getConversation(
+                Conversation.ConversationType.PRIVATE,
+                targetId, object : RongIMClient.ResultCallback<Conversation?>() {
+            override fun onSuccess(c: Conversation?) {
+                c?.let { it ->
+                    val oldDataIndex = adapter.data.indexOfFirst { it.conversation.targetId == targetId }
+                    if (oldDataIndex > -1) {
+                        adapter.remove(oldDataIndex)
+                    }
+                    val vo = ConversationListVo(it)
+                    vo.isOnline = true
+                    adapter.addData(0, vo)
+                    if (oldDataIndex == -1) {
+                        checkUserInfos(it.targetId)
+                    }
+                }
+            }
+
+            override fun onError(error: RongIMClient.ErrorCode?) {
+            }
+        })
+    }
+
+    private fun getSystemConversation() {
+        RongIMClient.getInstance().getConversation(Conversation.ConversationType.SYSTEM,
+                C.im.ROMG_SYSTEM_NOTICE, object : RongIMClient.ResultCallback<Conversation?>() {
+            override fun onSuccess(conversation: Conversation?) {
+                conversation?.let {
+                    val latestMessage = conversation.latestMessage
+                    headerBinding.tvYqLastMsg.text = IMChatUtils.checkMessageNotificationType(latestMessage)
+                    adapter.setUnReadCount(headerBinding.tvYqMsgCount, it.unreadMessageCount)
+                    headerBinding.tvYqTime.text = TimeUtils.millis2String(it.sentTime, sdf)
+                }
+            }
+
+            override fun onError(p0: RongIMClient.ErrorCode?) {
+                adapter.setUnReadCount(headerBinding.tvYqMsgCount)
+            }
+        })
+    }
+
+    private fun getPrivateConversationList() {
+        GlobalScope.launch(Dispatchers.Main) {
+            RongIMClient.getInstance().getConversationListByPage(
+                    object : RongIMClient.ResultCallback<MutableList<Conversation>?>() {
+                        override fun onSuccess(conversations: MutableList<Conversation>?) {
+                            if (conversations != null) {
+                                timeStamp = conversations.last().sentTime
+                                val formatConversation = DataFormat.imConversationList(conversations)
+                                adapter.addData(formatConversation)
+                                binding.srl.setEnableLoadMore(conversations.size >= 10)
+                                checkList()
+                                val ids = mutableListOf<String>()
+                                for (vo in formatConversation) {
+                                    ids.add(vo.conversation.targetId)
+                                }
+                                if (ids.size > 0) {
+                                    checkUserInfos(ids.listToString(","))
+                                }
+                            } else {
+                                binding.srl.setEnableLoadMore(false)
+                            }
+                            binding.srl.finishLoadMore()
+                        }
+
+                        override fun onError(errorCode: RongIMClient.ErrorCode?) {
+                            binding.srl.setNoMoreData(true)
+                            binding.srl.setEnableLoadMore(false)
+                            binding.srl.finishLoadMore()
+                        }
+                    }, timeStamp, 10, Conversation.ConversationType.PRIVATE)
+        }
+    }
+
+    // 加载用户头像
+    private fun loadUserAvatar() {
+        val loginInfo = AppManager.get().userLoginInfo
+        var url = ""
+        loginInfo?.let { url = it.headImg }
+        ImageLoader.get().loadAvatar(url, binding.civAvatar, R.drawable.ic_yq_tourists_avatar, R.drawable.ic_yq_tourists_avatar)
+    }
+
+    // 启动系统会话
+    private fun startSystemConversation() {
+        startConversation(
+                Conversation.ConversationType.SYSTEM,
+                C.im.ROMG_SYSTEM_NOTICE,
+                "友期小助手",
+                "")
+        thread {
+            clearMessagesUnreadStatus(Conversation.ConversationType.SYSTEM, C.im.ROMG_SYSTEM_NOTICE)
+            getSystemConversation()
+        }
+    }
+
+    // 启动私聊会话
+    private fun startListConversation(conversation: Conversation, position: Int) {
+        if (checkPrivateChat(childFragmentManager)) return
+        startConversation(conversation.conversationType,
+                conversation.targetId,
+                conversation.senderUserName,
+                conversation.portraitUrl)
+        conversation.unreadMessageCount = 0
+        notifyItemChanged(position, 333)
+        clearMessagesUnreadStatus(conversation.conversationType, conversation.targetId)
+    }
+
+    private fun startConversation(conversationType: Conversation.ConversationType,
+                                  targetId: String, targetUserName: String?, targetHeadImg: String?) {
+        if (TextUtils.isEmpty(targetId)) return
+        var name = targetUserName
+        var headImg = targetHeadImg
+        if (name == null) name = ""
+        if (headImg == null) headImg = ""
+        UChatConversationActivity.launch(mContext,
+                conversationType,
+                targetId,
+                name,
+                headImg,
+                Constant.conversation.ENTRY_TYPE_DEFAULT)
+
+    }
+
+    // 清除会话未读数,刷新首页tab未读数
+    private fun clearMessagesUnreadStatus(type: Conversation.ConversationType, targetId: String) {
+        RongIMClient.getInstance().clearMessagesUnreadStatus(type, targetId,
+                object : RongIMClient.ResultCallback<Boolean?>() {
+                    override fun onSuccess(aBoolean: Boolean?) {
+                        mainClient?.refreshUnreadNumber()
+                    }
+
+                    override fun onError(errorCode: RongIMClient.ErrorCode) {
+                        mainClient?.refreshUnreadNumber()
+                    }
+                })
+    }
+
+    // 局部刷新数据,加上 header
+    private fun notifyItemChanged(position: Int, payload: Int) {
+        adapter?.notifyItemChanged(position + adapter.headerLayoutCount, payload)
+    }
+
+    fun toTop() {
+        binding.rcv.smoothScrollToPosition(0)
+    }
+
+    fun loginSuccess() {
+        timeStamp = 0
+        lastRefreshTime = 0
+        IMChatUtils.connect(AppManager.get().userLoginInfo.rongCloudToken)
+    }
+
+    fun logOut() {
+        timeStamp = 0
+        lastRefreshTime = 0
+        adapter.setNewData(null)
+    }
+
+    private fun checkList() {
+        val currentTime = System.currentTimeMillis()
+        val refresh = currentTime - lastRefreshTime > C.app.REFRESH_INTERVAL
+        if (!refresh) return
+        lastRefreshTime = currentTime
+        if (adapter.data.size <= 0) return
+
+        val ids: MutableList<String> = ArrayList()
+        for (i in adapter.data.indices) {
+            val conversation: Conversation = adapter.data[i].conversation ?: continue
+            val targetId = conversation.targetId
+            if (TextUtils.isEmpty(targetId)) continue
+            ids.add(targetId)
+        }
+        if (ids.size > 0) {
+            val s = ids.listToString(",")
+            checkOnline(s)
+        }
+    }
+
+    // 检查在线
+    private fun checkOnline(ids: String?) {
+        if (TextUtils.isEmpty(ids)) return
+        execute(IMCore.get().checkOnlineState(ids), object : CoreCallback<List<IMUserOnlineState>?>() {
+            override fun onSuccess(chats: List<IMUserOnlineState>?) {
+                if (chats == null || chats.isEmpty()) return
+                val data = adapter.data
+                for (i in adapter.data.indices) {
+                    val vo = adapter.data[i]
+                    val conversation = vo.conversation
+                    val c = chats.firstOrNull { it.userId.toString() == conversation.targetId }
+                    if (c != null) {
+                        if (c.isOnlineStatus != vo.isOnline) {
+                            vo.isOnline = c.isOnlineStatus
+                            notifyItemChanged(i, 111)
+                        }
+                    }
+                }
+            }
+        })
+    }
+
+    // 检查用户信息是否能聊天
+    private fun checkUserInfos(ids: String) {
+        if (TextUtils.isEmpty(ids)) return
+        execute(IMCore.get().checkCanChat(ids), object : CoreCallback<List<IMCheckChat>?>() {
+            override fun onSuccess(chats: List<IMCheckChat>?) {
+                if (chats != null && chats.isNotEmpty()) {
+                    for (chat in chats) {
+                        val index = adapter.data.indexOfFirst { it.conversation.targetId == chat.userId.toString() }
+                        if (index > -1) {
+                            adapter.data[index].chat = chat
+                            notifyItemChanged(index, 222)
+                        }
+                    }
+                }
+            }
+        })
+    }
+
+    override fun onVisible() {
+        super.onVisible()
+        StatusBarUtils.statusBarDarkFont(mContext, true)
+        mainClient?.let {
+            it.setMainTabStyle(CommonConfig.FLAG_MSG, false, false, false, false)
+            loadUserAvatar()
+        }
+        checkList()
+        checkNotifyEnable()
+    }
+
+    override fun onHidden() {
+        super.onHidden()
+    }
+
+    override fun onDestroyView() {
+        adapter?.release()
+        super.onDestroyView()
+    }
+
+}

+ 4 - 2
app/src/main/java/com/shanp/youqi/app/fragment/MainFragment.java

@@ -110,7 +110,8 @@ public class MainFragment extends UChatFragment {
     private boolean mCurrentTabBgColorIsTransparent = false;
     private RoomListFragment mRoomListFragment;
     private UChatHintDialog mLogoutDialog;
-    private ChatMessageListFragment mChatMsgFragment;
+//    private ChatMessageListFragment mChatMsgFragment;
+    private ChatMessageListFragmentKotlin mChatMsgFragment;
     // 是否需要弹出强退的弹窗
     private boolean mIsNeedShowLogOutDialog = false;
     private NotificationHelper notificationHelper;
@@ -245,7 +246,8 @@ public class MainFragment extends UChatFragment {
         mRoomListFragment = new RoomListFragment();
         mFoundHomePageFragment = new FoundHomePageFragment();
         mFocusHomeFragment = new FocusHomeFragment();
-        mChatMsgFragment = new ChatMessageListFragment();
+//        mChatMsgFragment = new ChatMessageListFragment();
+        mChatMsgFragment = new ChatMessageListFragmentKotlin();
 
         List<Fragment> mFragments = new LinkedList<>();
         mFragments.add(mRoomListFragment);

+ 73 - 0
app/src/main/res/layout/main_fragment_uqchat_msg_kotlin.xml

@@ -0,0 +1,73 @@
+<?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"
+    android:id="@+id/ll_root_layout"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/white"
+    android:orientation="vertical">
+
+    <com.shanp.youqi.common.widget.UCharFitStatusBarView
+        android:id="@+id/fit_status_bar_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+
+    <!-- 头部 -->
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/rl_top_view"
+        android:layout_width="match_parent"
+        android:layout_height="44dp">
+
+        <!-- 左上角头像 -->
+        <de.hdodenhof.circleimageview.CircleImageView
+            android:id="@+id/civ_avatar"
+            android:layout_width="30dp"
+            android:layout_height="30dp"
+            android:layout_marginStart="15dp"
+            android:src="@drawable/ic_yq_tourists_avatar"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="消息"
+            android:textColor="@color/color_333333"
+            android:textSize="18sp"
+            android:textStyle="bold"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <View
+        android:id="@+id/v_line"
+        android:layout_width="match_parent"
+        android:layout_height="1px"
+        android:background="@color/color_E6E6E6" />
+
+    <com.scwang.smartrefresh.layout.SmartRefreshLayout
+        android:id="@+id/srl"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1"
+        app:srlEnableAutoLoadMore="false"
+        app:srlEnableRefresh="false">
+
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/rcv"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:overScrollMode="never"
+            android:splitMotionEvents="false" />
+    </com.scwang.smartrefresh.layout.SmartRefreshLayout>
+
+    <View
+        android:id="@+id/v_bottom"
+        android:layout_width="match_parent"
+        android:layout_height="49dp" />
+
+</LinearLayout>

+ 483 - 0
app/src/main/res/layout/main_item_message_header_kotlin.xml

@@ -0,0 +1,483 @@
+<?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="vertical">
+
+
+    <RelativeLayout
+        android:id="@+id/rl_open_notify_layout"
+        android:layout_width="match_parent"
+        android:layout_height="44dp"
+        android:background="@color/color_F4EEFF"
+        android:visibility="gone"
+        tools:visibility="visible">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_marginStart="15dp"
+            android:gravity="center_vertical"
+            android:text="打开通知才可以收到喜欢的人消息哦"
+            android:textColor="@color/color_9C6CFA"
+            android:textSize="14sp" />
+
+        <TextView
+            android:id="@+id/tv_open_notify"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentEnd="true"
+            android:layout_centerVertical="true"
+            android:layout_marginEnd="15dp"
+            android:background="@drawable/im_bg_open_notify"
+            android:paddingStart="9.5dp"
+            android:paddingTop="3dp"
+            android:paddingEnd="9.5dp"
+            android:paddingBottom="3dp"
+            android:text="去开启"
+            android:textColor="@color/color_9C6CFA" />
+    </RelativeLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="109dp"
+        android:gravity="center_vertical">
+
+        <androidx.constraintlayout.widget.ConstraintLayout
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1">
+
+            <de.hdodenhof.circleimageview.CircleImageView
+                android:id="@+id/civ_like_me"
+                android:layout_width="45dp"
+                android:layout_height="45dp"
+                android:src="@drawable/im_ic_top_like_me"
+                app:layout_constraintBottom_toTopOf="@id/tv_like_me"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="parent"
+                app:layout_constraintVertical_chainStyle="packed" />
+
+            <de.hdodenhof.circleimageview.CircleImageView
+                android:id="@+id/civ_like_me_mask"
+                android:layout_width="45dp"
+                android:layout_height="45dp"
+                android:src="#4D9C6BFA"
+                android:visibility="gone"
+                app:layout_constraintBottom_toBottomOf="@id/civ_like_me"
+                app:layout_constraintEnd_toEndOf="@id/civ_like_me"
+                app:layout_constraintStart_toStartOf="@id/civ_like_me"
+                app:layout_constraintTop_toTopOf="@id/civ_like_me" />
+
+            <TextView
+                android:id="@+id/tv_like_me"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="5dp"
+                android:gravity="center"
+                android:text="喜欢我的"
+                android:textColor="@color/color_333333"
+                android:textSize="13sp"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/civ_like_me" />
+
+            <View
+                android:id="@+id/tv_like_me_number"
+                android:layout_width="8dp"
+                android:layout_height="8dp"
+                android:background="@drawable/im_bg_number"
+                app:layout_constraintEnd_toEndOf="@id/civ_like_me"
+                app:layout_constraintStart_toEndOf="@id/civ_like_me"
+                app:layout_constraintTop_toTopOf="@id/civ_like_me" />
+
+        </androidx.constraintlayout.widget.ConstraintLayout>
+
+        <androidx.constraintlayout.widget.ConstraintLayout
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1">
+
+            <de.hdodenhof.circleimageview.CircleImageView
+                android:id="@+id/civ_each_like"
+                android:layout_width="45dp"
+                android:layout_height="45dp"
+                android:src="@drawable/im_msg_ic_each_like"
+                app:layout_constraintBottom_toTopOf="@id/tv_each_like"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="parent"
+                app:layout_constraintVertical_chainStyle="packed" />
+
+            <TextView
+                android:id="@+id/tv_each_like"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="5dp"
+                android:gravity="center"
+                android:text="互相喜欢"
+                android:textColor="@color/color_333333"
+                android:textSize="13sp"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/civ_each_like" />
+
+        </androidx.constraintlayout.widget.ConstraintLayout>
+
+        <androidx.constraintlayout.widget.ConstraintLayout
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1">
+
+            <de.hdodenhof.circleimageview.CircleImageView
+                android:id="@+id/civ_live_user"
+                android:layout_width="45dp"
+                android:layout_height="45dp"
+                android:src="@drawable/im_msg_ic_like"
+                app:layout_constraintBottom_toTopOf="@id/tv_live_user"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="parent"
+                app:layout_constraintVertical_chainStyle="packed" />
+
+            <TextView
+                android:id="@+id/tv_live_user"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="5dp"
+                android:gravity="center"
+                android:text="我喜欢的"
+                android:textColor="@color/color_333333"
+                android:textSize="13sp"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/civ_live_user" />
+
+        </androidx.constraintlayout.widget.ConstraintLayout>
+
+
+        <androidx.constraintlayout.widget.ConstraintLayout
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1">
+
+            <de.hdodenhof.circleimageview.CircleImageView
+                android:id="@+id/civ_visitor"
+                android:layout_width="45dp"
+                android:layout_height="45dp"
+                android:src="@drawable/im_ic_top_visitor"
+                app:layout_constraintBottom_toTopOf="@id/tv_visitor"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="parent"
+                app:layout_constraintVertical_chainStyle="packed" />
+
+            <de.hdodenhof.circleimageview.CircleImageView
+                android:id="@+id/civ_visitor_mask"
+                android:layout_width="45dp"
+                android:layout_height="45dp"
+                android:src="#4D9C6BFA"
+                android:visibility="gone"
+                app:layout_constraintBottom_toBottomOf="@id/civ_visitor"
+                app:layout_constraintEnd_toEndOf="@id/civ_visitor"
+                app:layout_constraintStart_toStartOf="@id/civ_visitor"
+                app:layout_constraintTop_toTopOf="@id/civ_visitor" />
+
+            <TextView
+                android:id="@+id/tv_visitor"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="5dp"
+                android:gravity="center"
+                android:text="访客足迹"
+                android:textColor="@color/color_333333"
+                android:textSize="13sp"
+                app:layout_constraintBottom_toBottomOf="parent"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@id/civ_visitor" />
+
+            <View
+                android:id="@+id/tv_visitor_number"
+                android:layout_width="8dp"
+                android:layout_height="8dp"
+                android:background="@drawable/im_bg_number"
+                app:layout_constraintEnd_toEndOf="@id/civ_visitor"
+                app:layout_constraintStart_toEndOf="@id/civ_visitor"
+                app:layout_constraintTop_toTopOf="@id/civ_visitor" />
+        </androidx.constraintlayout.widget.ConstraintLayout>
+
+
+    </LinearLayout>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="10dp"
+        android:background="@color/color_F7F7F7" />
+
+    <RelativeLayout
+        android:id="@+id/rl_find_the_boss_layout"
+        android:layout_width="match_parent"
+        android:layout_height="80dp"
+        android:foreground="?android:attr/selectableItemBackground"
+        android:gravity="center_vertical"
+        android:visibility="gone"
+        tools:visibility="visible">
+
+        <ImageView
+            android:id="@+id/iv_find_the_boss_icon"
+            android:layout_width="50dp"
+            android:layout_height="50dp"
+            android:layout_centerVertical="true"
+            android:layout_marginStart="15dp"
+            android:scaleType="centerCrop"
+            android:src="@drawable/main_ic_find_boss" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_marginStart="10dp"
+            android:layout_toEndOf="@id/iv_find_the_boss_icon"
+            android:gravity="center"
+            android:text="发现老板"
+            android:textColor="@color/color_333333"
+            android:textSize="16sp" />
+
+        <RelativeLayout
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_alignParentEnd="true"
+            android:gravity="center_vertical">
+
+            <com.shanp.youqi.common.widget.UQCarouselAvatarView
+                android:id="@+id/dav_avatar"
+                android:layout_width="130dp"
+                android:layout_height="33dp"
+                android:layout_centerVertical="true"
+                app:uq_dav_isBlur="false"
+                app:uq_dav_isLastComplete="true"
+                app:uq_dav_isShowAnimation="true"
+                app:uq_dav_maxCount="3"
+                app:uq_dav_radius="16"
+                app:uq_dav_space="0.5" />
+        </RelativeLayout>
+
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="1px"
+            android:layout_alignParentBottom="true"
+            android:layout_marginStart="75dp"
+            android:background="@color/color_E6E6E6" />
+    </RelativeLayout>
+
+
+    <RelativeLayout
+        android:id="@+id/rl_praise_self_layout"
+        android:layout_width="match_parent"
+        android:layout_height="80dp"
+        android:foreground="?android:attr/selectableItemBackground"
+        android:gravity="center_vertical">
+
+        <ImageView
+            android:id="@+id/iv_praise_self_icon"
+            android:layout_width="50dp"
+            android:layout_height="50dp"
+            android:layout_centerVertical="true"
+            android:layout_marginStart="15dp"
+            android:scaleType="centerCrop"
+            android:src="@drawable/im_ic_interact_message" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_marginStart="10dp"
+            android:layout_toEndOf="@id/iv_praise_self_icon"
+            android:gravity="center"
+            android:text="互动消息"
+            android:textColor="@color/color_333333"
+            android:textSize="16sp" />
+
+        <TextView
+            android:id="@+id/tv_praise_self_number"
+            android:layout_width="8dp"
+            android:layout_height="8dp"
+            android:layout_alignParentEnd="true"
+            android:layout_centerVertical="true"
+            android:layout_marginEnd="22dp"
+            android:background="@drawable/im_bg_number_fill"
+            android:visibility="invisible" />
+    </RelativeLayout>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1px"
+        android:layout_marginStart="75dp"
+        android:background="@color/color_E6E6E6" />
+
+    <RelativeLayout
+        android:id="@+id/rl_order_message_layout"
+        android:layout_width="match_parent"
+        android:layout_height="80dp"
+        android:foreground="?android:attr/selectableItemBackground"
+        android:gravity="center_vertical">
+
+        <ImageView
+            android:id="@+id/iv_order_message_icon"
+            android:layout_width="50dp"
+            android:layout_height="50dp"
+            android:layout_centerVertical="true"
+            android:layout_marginStart="15dp"
+            android:scaleType="centerCrop"
+            android:src="@drawable/im_ic_order_message" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_marginStart="10dp"
+            android:layout_toEndOf="@id/iv_order_message_icon"
+            android:gravity="center"
+            android:text="订单消息"
+            android:textColor="@color/color_333333"
+            android:textSize="16sp" />
+
+        <TextView
+            android:id="@+id/tv_order_message_number"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentEnd="true"
+            android:layout_centerVertical="true"
+            android:layout_marginEnd="15dp"
+            android:background="@drawable/im_bg_number_fill"
+            android:gravity="center"
+            android:lines="1"
+            android:paddingStart="6dp"
+            android:paddingTop="1dp"
+            android:paddingEnd="6dp"
+            android:paddingBottom="1dp"
+            android:singleLine="true"
+            android:textColor="@color/white"
+            android:textSize="12sp"
+            android:visibility="invisible"
+            tools:text="1"
+            tools:visibility="visible" />
+
+    </RelativeLayout>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1px"
+        android:layout_marginStart="75dp"
+        android:background="@color/color_E6E6E6" />
+
+    <!--    友期小助手 -->
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/cl_yq_conversation_layout"
+        android:layout_width="match_parent"
+        android:foreground="?android:attr/selectableItemBackground"
+        android:layout_height="80dp">
+
+        <de.hdodenhof.circleimageview.CircleImageView
+            android:id="@+id/civ_yq_avatar"
+            android:layout_width="50dp"
+            android:layout_height="50dp"
+            android:layout_marginStart="15dp"
+            android:src="@drawable/ic_yq_tourists_avatar"
+            app:layout_constraintBottom_toTopOf="@id/v_line"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <View
+            android:id="@+id/v_yq_online_state"
+            android:layout_width="12dp"
+            android:layout_height="12dp"
+            android:background="@drawable/im_ic_online_icon"
+            app:layout_constraintBottom_toBottomOf="@id/civ_yq_avatar"
+            app:layout_constraintEnd_toEndOf="@id/civ_yq_avatar" />
+
+        <TextView
+            android:id="@+id/tv_yq_user_name"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="10dp"
+            android:layout_marginBottom="3dp"
+            android:singleLine="true"
+            android:text="友期小助手"
+            android:textColor="@color/color_333333"
+            android:textSize="16sp"
+            app:layout_constraintBottom_toTopOf="@id/tv_yq_last_msg"
+            app:layout_constraintHorizontal_chainStyle="packed"
+            app:layout_constraintStart_toEndOf="@id/civ_yq_avatar"
+            app:layout_constraintTop_toTopOf="@id/civ_yq_avatar" />
+
+        <View
+            android:id="@+id/v_yq_official"
+            android:layout_width="28dp"
+            android:layout_height="14dp"
+            android:layout_marginStart="8dp"
+            android:background="@drawable/im_ic_yq_icon"
+            android:visibility="visible"
+            app:layout_constraintBottom_toBottomOf="@id/tv_yq_user_name"
+            app:layout_constraintStart_toEndOf="@id/tv_yq_user_name"
+            app:layout_constraintTop_toTopOf="@id/tv_yq_user_name" />
+
+
+        <TextView
+            android:id="@+id/tv_yq_last_msg"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="10dp"
+            android:layout_marginEnd="20dp"
+            android:maxWidth="328dp"
+            android:singleLine="true"
+            android:textColor="@color/color_999999"
+            android:textSize="14sp"
+            app:layout_constraintBottom_toBottomOf="@id/civ_yq_avatar"
+            app:layout_constraintEnd_toStartOf="@id/tv_yq_msg_count"
+            app:layout_constraintStart_toEndOf="@id/civ_yq_avatar"
+            app:layout_constraintTop_toBottomOf="@id/tv_yq_user_name"
+            tools:text="恭喜你,成功的开通了VIP权限特权" />
+
+        <TextView
+            android:id="@+id/tv_yq_time"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="15dp"
+            android:textColor="@color/color_B4B4B4"
+            android:textSize="12sp"
+            app:layout_constraintBottom_toBottomOf="@id/tv_yq_user_name"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="@id/tv_yq_user_name"
+            tools:text="刚刚" />
+
+        <TextView
+            android:id="@+id/tv_yq_msg_count"
+            android:layout_width="wrap_content"
+            android:layout_height="16dp"
+            android:layout_marginEnd="15dp"
+            android:background="@drawable/bg_msg_unread_num"
+            android:gravity="center"
+            android:includeFontPadding="false"
+            android:textColor="@color/white"
+            android:textSize="12sp"
+            app:layout_constraintBottom_toBottomOf="@id/tv_yq_last_msg"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="@id/tv_yq_last_msg"
+            tools:text="12" />
+
+
+        <View
+            android:id="@+id/v_line"
+            android:layout_width="match_parent"
+            android:layout_height="1px"
+            android:layout_marginStart="75dp"
+            android:background="@color/color_E6E6E6"
+            app:layout_constraintBottom_toBottomOf="parent" />
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+</LinearLayout>

+ 108 - 0
app/src/main/res/layout/main_item_msg_list_layout.xml

@@ -0,0 +1,108 @@
+<?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"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="81dp"
+    android:foreground="?android:attr/selectableItemBackground">
+
+    <de.hdodenhof.circleimageview.CircleImageView
+        android:id="@+id/civ_item_avatar"
+        android:layout_width="50dp"
+        android:layout_height="50dp"
+        android:layout_marginStart="15dp"
+        android:src="@drawable/ic_yq_tourists_avatar"
+        app:layout_constraintBottom_toTopOf="@id/v_line"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        tools:src="@drawable/icon_def_avatar" />
+
+    <View
+        android:id="@+id/v_im_conversation_online_state"
+        android:layout_width="12dp"
+        android:layout_height="12dp"
+        android:background="@drawable/im_ic_online_icon"
+        app:layout_constraintBottom_toBottomOf="@id/civ_item_avatar"
+        app:layout_constraintEnd_toEndOf="@id/civ_item_avatar" />
+
+    <TextView
+        android:id="@+id/tv_item_user_name"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="10dp"
+        android:layout_marginBottom="3dp"
+        android:singleLine="true"
+        android:textColor="@color/color_333333"
+        android:textSize="16sp"
+        app:layout_constraintBottom_toTopOf="@id/tv_item_last_msg"
+        app:layout_constraintHorizontal_chainStyle="packed"
+        app:layout_constraintStart_toEndOf="@id/civ_item_avatar"
+        app:layout_constraintTop_toTopOf="@id/civ_item_avatar"
+        tools:text="有期助手" />
+
+    <View
+        android:id="@+id/v_each_like_flag"
+        android:layout_width="15dp"
+        android:layout_height="15dp"
+        android:layout_marginStart="8dp"
+        android:background="@drawable/im_ic_each_like_flag"
+        android:visibility="gone"
+        app:layout_constraintBottom_toBottomOf="@id/tv_item_user_name"
+        app:layout_constraintStart_toEndOf="@id/tv_item_user_name"
+        app:layout_constraintTop_toTopOf="@id/tv_item_user_name"
+        tools:visibility="visible" />
+
+    <TextView
+        android:id="@+id/tv_item_last_msg"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="10dp"
+        android:layout_marginEnd="20dp"
+        android:maxWidth="328dp"
+        android:singleLine="true"
+        android:textColor="@color/color_999999"
+        android:textSize="14sp"
+        app:layout_constraintBottom_toBottomOf="@id/civ_item_avatar"
+        app:layout_constraintEnd_toStartOf="@id/tv_item_msg_count"
+        app:layout_constraintStart_toEndOf="@id/civ_item_avatar"
+        app:layout_constraintTop_toBottomOf="@id/tv_item_user_name"
+        tools:text="恭喜你,成功的开通了VIP权限特权" />
+
+    <TextView
+        android:id="@+id/tv_item_time"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginEnd="15dp"
+        android:textColor="@color/color_B4B4B4"
+        android:textSize="12sp"
+        app:layout_constraintBottom_toBottomOf="@id/tv_item_user_name"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="@id/tv_item_user_name"
+        tools:text="刚刚" />
+
+    <TextView
+        android:id="@+id/tv_item_msg_count"
+        android:layout_width="wrap_content"
+        android:layout_height="16dp"
+        android:layout_marginEnd="15dp"
+        android:background="@drawable/bg_msg_unread_num"
+        android:gravity="center"
+        android:includeFontPadding="false"
+        android:textColor="@color/white"
+        android:textSize="12sp"
+        android:visibility="invisible"
+        app:layout_constraintBottom_toBottomOf="@id/tv_item_last_msg"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="@id/tv_item_last_msg"
+        tools:text="12"
+        tools:visibility="visible" />
+
+    <View
+        android:id="@+id/v_line"
+        android:layout_width="match_parent"
+        android:layout_height="1px"
+        android:layout_marginStart="75dp"
+        android:background="@color/color_E6E6E6"
+        app:layout_constraintBottom_toBottomOf="parent" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 4 - 2
uchat_common/src/main/java/com/shanp/youqi/common/ui/dialog/CustomDelDialog.java

@@ -56,12 +56,14 @@ public class CustomDelDialog extends BaseDialogFragment {
     private boolean mIsSelf = false;
 
     // 每次都设置
-    public void setIsSelf(boolean isSelf) {
+    public CustomDelDialog setIsSelf(boolean isSelf) {
         this.mIsSelf = isSelf;
+        return this;
     }
 
-    public void setListener(ResultHandler listener) {
+    public CustomDelDialog setListener(ResultHandler listener) {
         this.listener = listener;
+        return this;
     }
 
 }

+ 20 - 0
uchat_common/src/main/java/com/shanp/youqi/common/utils/ExtensionUtils.kt

@@ -0,0 +1,20 @@
+package com.shanp.youqi.common.utils
+
+/**
+ * yzs
+ * 11/27/20.
+ */
+
+fun MutableList<String>?.listToString(separator: String): String {
+    if (this == null) return ""
+    val sb = StringBuilder()
+    for (i in this.indices) {
+        if (i == this.size - 1) {
+            sb.append(this[i])
+        } else {
+            sb.append(this[i])
+            sb.append(separator)
+        }
+    }
+    return sb.toString()
+}

+ 13 - 1
uchat_core/src/main/java/com/shanp/youqi/core/account/UserCore.java

@@ -29,7 +29,6 @@ import com.shanp.youqi.core.model.UserMenu;
 import com.shanp.youqi.core.model.UserMine;
 import com.shanp.youqi.core.model.UserMoreInfo;
 import com.shanp.youqi.core.model.UserRegion;
-import com.shanp.youqi.core.model.UserReportType;
 import com.shanp.youqi.core.model.UserSkillVoice;
 import com.shanp.youqi.core.model.UserTag;
 import com.shanp.youqi.core.model.UserVerified;
@@ -95,6 +94,19 @@ public class UserCore extends AbstractRepository {
         return get(U.api.USER_BASE_USER_INFO, param).map(single(UserBaseInfo.class));
     }
 
+
+    //用户基础信息
+    public UserBaseInfo baseUserInfoDoGet(String userId) {
+        Map<String, String> param = new HashMap<>();
+        param.put("userId", userId);
+        try {
+            return doGet(U.api.USER_BASE_USER_INFO, param).getResult(UserBaseInfo.class);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
     //用户更多信息
     public Observable<UserMoreInfo> moreInfo(String userId) {
         Map<String, String> param = new HashMap<>();

+ 71 - 0
uchat_im/src/main/java/com/shanp/youqi/im/util/IMChatUtils.java

@@ -2,9 +2,15 @@ package com.shanp.youqi.im.util;
 
 import android.net.Uri;
 
+import com.blankj.utilcode.util.ToastUtils;
+import com.shanp.youqi.base.rx.RxBus;
 import com.shanp.youqi.base.util.LogUtil;
+import com.shanp.youqi.core.event.IMConnectSuccessEvent;
+import com.shanp.youqi.core.event.LogOutEvent;
 import com.shanp.youqi.core.im.vo.CustomAppSystemTypeMessage;
 import com.shanp.youqi.core.im.vo.CustomPlayOrderStateMessage;
+import com.shanp.youqi.core.memory.AppManager;
+import com.shanp.youqi.im.IMBuilder;
 import com.shanp.youqi.im.config.IMConfig;
 import com.shanp.youqi.im.vo.ConversationItemVo;
 import com.shanp.youqi.im.vo.MsgType;
@@ -417,4 +423,69 @@ public class IMChatUtils {
         }
         return lastMessage;
     }
+
+
+    /**
+     * 连接融云
+     */
+    public static void connect(String token) {
+        IMBuilder.initMessageType();
+        RongIMClient.getInstance().logout();
+
+        /**
+         * 设置连接状态的监听。
+         */
+        RongIMClient.setConnectionStatusListener(new RongIMClient.ConnectionStatusListener() {
+
+            /**
+             * CONN_USER_BLOCKED 用户被开发者后台封禁
+             * CONNECTED 连接成功。
+             * CONNECTING 连接中。
+             * DISCONNECTED 断开连接。
+             * KICKED_OFFLINE_BY_OTHER_CLIENT 用户账户在其他设备登录,本机会被踢掉线。
+             * NETWORK_UNAVAILABLE 网络不可用。
+             * SERVER_INVALID 服务器异常或无法连接。
+             * TOKEN_INCORRECT Token 不正确。
+             */
+            @Override
+            public void onChanged(RongIMClient.ConnectionStatusListener.ConnectionStatus status) {
+                LogUtil.d("融云changed " + status.name() + "    " + status.getMessage() + "    " + status.getValue());
+                if (status == ConnectionStatus.CONNECTED) {
+                    AppManager.get().setConnectRongCloud(true);
+                } else {
+                    AppManager.get().setConnectRongCloud(false);
+                    if (status == ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT) {
+                        AppManager.get().logOut(LogOutEvent.Type.TYPE_COMMPEL);
+                    } else if (status == ConnectionStatus.TOKEN_INCORRECT) {
+                        AppManager.get().setConnectRongCloud(false);
+                        AppManager.get().logOut(LogOutEvent.Type.TYPE_NATURE);
+                        ToastUtils.showLong("登录信息失效,请重新登录");
+                    } else if (status == ConnectionStatus.CONN_USER_BLOCKED) {
+                        AppManager.get().logOut(LogOutEvent.Type.TYPE_ACCOUNT_FREEZE);
+                    }
+                }
+            }
+        });
+
+
+        RongIMClient.connect(token, new RongIMClient.ConnectCallback() {
+            @Override
+            public void onSuccess(String userId) {
+                AppManager.get().setConnectRongCloud(true);
+                LogUtil.d("融云changed  " + userId);
+                RxBus.get().post(new IMConnectSuccessEvent());
+            }
+
+            @Override
+            public void onError(RongIMClient.ConnectionErrorCode errorCode) {
+                AppManager.get().setConnectRongCloud(false);
+            }
+
+            @Override
+            public void onDatabaseOpened(RongIMClient.DatabaseOpenStatus databaseOpenStatus) {
+                AppManager.get().setConnectRongCloud(true);
+                IMBuilder.initMessageType();
+            }
+        });
+    }
 }