146 lines
4.9 KiB
Kotlin
146 lines
4.9 KiB
Kotlin
|
|
package com.xscm.modulemain.activity
|
||
|
|
|
||
|
|
import android.content.Intent
|
||
|
|
import android.view.View
|
||
|
|
import android.widget.CompoundButton
|
||
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||
|
|
import com.blankj.utilcode.util.ToastUtils
|
||
|
|
import com.tencent.imsdk.v2.V2TIMCallback
|
||
|
|
import com.tencent.imsdk.v2.V2TIMGroupManager
|
||
|
|
import com.tencent.imsdk.v2.V2TIMManager
|
||
|
|
import com.xscm.modulemain.BaseMvpActivity
|
||
|
|
import com.xscm.modulemain.R
|
||
|
|
import com.xscm.modulemain.activity.msg.NewsContacts
|
||
|
|
import com.xscm.modulemain.activity.msg.NewsPresenter
|
||
|
|
import com.xscm.modulemain.adapter.GroupAdapter
|
||
|
|
import com.xscm.modulemain.databinding.ActivityGroupChatSettingsBinding
|
||
|
|
import com.xscm.moduleutil.bean.GroupBean
|
||
|
|
import com.xscm.moduleutil.bean.GroupUserListBean
|
||
|
|
import com.xscm.moduleutil.bean.NewsMessageList
|
||
|
|
import com.xscm.moduleutil.utils.ImageUtils
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @Author
|
||
|
|
* @Time 2026/1/2 14:57
|
||
|
|
* @Description 群聊设置
|
||
|
|
*/
|
||
|
|
class GroupChatSettingsActivity :
|
||
|
|
BaseMvpActivity<NewsPresenter, ActivityGroupChatSettingsBinding>(),
|
||
|
|
NewsContacts.View {
|
||
|
|
|
||
|
|
var groupAdapter: GroupAdapter? = GroupAdapter()
|
||
|
|
val v2TIMGroupManager: V2TIMGroupManager?= V2TIMManager.getGroupManager()
|
||
|
|
var groupId: String = ""
|
||
|
|
var isOwner : Boolean = false
|
||
|
|
|
||
|
|
var groupBean : GroupBean= GroupBean()
|
||
|
|
|
||
|
|
override fun bindPresenter(): NewsPresenter {
|
||
|
|
return NewsPresenter(this, this)
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
override fun initData() {
|
||
|
|
mBinding?.topBar?.tvTitle?.text = "群聊设置"
|
||
|
|
MvpPre?.getGuildInfo(groupId)
|
||
|
|
// 设置布局管理器
|
||
|
|
mBinding?.rvGroupMember?.apply {
|
||
|
|
layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||
|
|
// 可选:设置是否固定大小
|
||
|
|
setHasFixedSize(true)
|
||
|
|
// 设置适配器
|
||
|
|
adapter = groupAdapter
|
||
|
|
}
|
||
|
|
|
||
|
|
mBinding?.tvGroupCount?.setOnClickListener {
|
||
|
|
val intent = Intent(this, GroupUserListActivity::class.java).apply {
|
||
|
|
putExtra("groupId", groupId)
|
||
|
|
putExtra("isOwner", isOwner)
|
||
|
|
}
|
||
|
|
startActivity(intent)
|
||
|
|
}
|
||
|
|
|
||
|
|
mBinding?.tvConfirm?.setOnClickListener {
|
||
|
|
if(mBinding?.evGroupName?.text.toString().equals(groupBean.name) && mBinding?.etG?.text.toString().equals(groupBean.notification)){
|
||
|
|
finish()
|
||
|
|
}else if (mBinding?.evGroupName?.text.toString().equals(groupBean.name) && !mBinding?.etG?.text.toString().equals(groupBean.notification)){
|
||
|
|
MvpPre?.setGuildInfo(groupId, "", mBinding?.etG?.text.toString(), "")
|
||
|
|
}else if (!mBinding?.evGroupName?.text.toString().equals(groupBean.name) && mBinding?.etG?.text.toString().equals(groupBean.notification)){
|
||
|
|
MvpPre?.setGuildInfo(groupId, mBinding?.evGroupName?.text.toString(), "", "")
|
||
|
|
}else {
|
||
|
|
MvpPre?.setGuildInfo(
|
||
|
|
groupId,
|
||
|
|
mBinding?.evGroupName?.text.toString(),
|
||
|
|
mBinding?.etG?.text.toString(),
|
||
|
|
""
|
||
|
|
)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
mBinding?.switJy?.setOnCheckedChangeListener { compoundButton, b ->
|
||
|
|
v2TIMGroupManager?.muteAllGroupMembers(groupId, b, object : V2TIMCallback {
|
||
|
|
override fun onSuccess() {
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
override fun onError(code: Int, desc: String?) {
|
||
|
|
mBinding?.switJy?.isChecked = !b
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
override fun getLayoutId(): Int {
|
||
|
|
return R.layout.activity_group_chat_settings
|
||
|
|
}
|
||
|
|
|
||
|
|
override fun showNews(newsList: List<NewsMessageList?>?) {
|
||
|
|
}
|
||
|
|
|
||
|
|
override fun finishRefresh() {
|
||
|
|
}
|
||
|
|
|
||
|
|
override fun postInvite() {
|
||
|
|
}
|
||
|
|
|
||
|
|
override fun getGuildInfo(groupBean: GroupBean?) {
|
||
|
|
if (groupBean == null) {
|
||
|
|
finish()
|
||
|
|
return
|
||
|
|
}
|
||
|
|
this.groupBean=groupBean
|
||
|
|
mBinding?.groupName?.text = groupBean.name
|
||
|
|
ImageUtils.loadHead(groupBean.guild_cover, mBinding?.imGroup)
|
||
|
|
if (groupBean.is_deacon == 1) {
|
||
|
|
isOwner=true
|
||
|
|
mBinding?.llGroup?.visibility = View.VISIBLE
|
||
|
|
mBinding?.switJy?.isChecked = groupBean.mute_all_member == 1
|
||
|
|
mBinding?.etG?.isEnabled = true
|
||
|
|
mBinding?.evGroupName?.isEnabled = true
|
||
|
|
} else {
|
||
|
|
isOwner=false
|
||
|
|
mBinding?.llGroup?.visibility = View.GONE
|
||
|
|
mBinding?.etG?.isEnabled = false
|
||
|
|
mBinding?.evGroupName?.isEnabled = false
|
||
|
|
}
|
||
|
|
mBinding?.etG?.text?.append(groupBean.notification)
|
||
|
|
mBinding?.evGroupName?.text?.append(groupBean.name)
|
||
|
|
|
||
|
|
groupAdapter?.setNewData(groupBean.user_list)
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
override fun setGuildInfo(s: String?) {
|
||
|
|
ToastUtils.showLong(s)
|
||
|
|
finish()
|
||
|
|
}
|
||
|
|
|
||
|
|
override fun memberList(groupUserListBean: GroupUserListBean?) {
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
override fun doDone() {
|
||
|
|
super.doDone()
|
||
|
|
groupId = intent.getStringExtra("groupId").toString()
|
||
|
|
}
|
||
|
|
}
|