package com.swago.room.dialog

import android.os.Bundle
import android.view.Gravity
import android.view.View
import com.alibaba.android.arouter.launcher.ARouter
import com.gyf.immersionbar.ImmersionBar
import com.swago.baseswago.constant.ARouteConstant
import com.swago.baseswago.dialog.BaseXDFragment
import com.swago.baseswago.util.NoDoubleClickListener
import com.swago.room.databinding.DialogMessageListBinding
import com.tencent.imsdk.v2.V2TIMConversation
import com.tencent.qcloud.tim.uikit.modules.conversation.ConversationLayout
import com.tencent.qcloud.tim.uikit.modules.conversation.ConversationManagerKit

/**
 *@date 2021/11/11 21:03
 *description:
 */
class MessageListDialog : BaseXDFragment<DialogMessageListBinding>() {

    init {
        setDimAmount(0f)
        setGravity(Gravity.BOTTOM)
    }

   companion object{
       fun newInstance(): MessageListDialog {
           val args = Bundle()
           val fragment = MessageListDialog()
           fragment.arguments = args
           return fragment
       }
   }


    override fun initOther() {
        activity?.let {
            binding.conversation.initDefault()
            binding.conversation.conversationList.setOnItemClickListener { view, position, messageInfo ->
                ARouter.getInstance().build(ARouteConstant.Home.chatDetail)
                    .withInt("type", V2TIMConversation.V2TIM_C2C)
                    .withString("account",messageInfo.id)
                    .withString("chatName",messageInfo.title).navigation()
            }

            binding.conversation.conversationList.setOnItemLongClickListener { view, position, messageInfo ->

            }

        }
    }

    override fun initLiveData() {}
    override fun onDestroyView() {
        ConversationManagerKit.getInstance().detachAdapter()
        super.onDestroyView()
    }
}