feat:游戏房公屏默认添加第一条系统公告

This commit is contained in:
max
2024-05-31 14:03:01 +08:00
parent 92a0e4b408
commit 126215949f
3 changed files with 22 additions and 3 deletions

View File

@@ -1,10 +1,12 @@
package com.chwl.app.game.core
import com.chwl.app.R
import com.chwl.core.support.listener.ListenerOwner
import com.chwl.core.support.listener.ListenerStore
import com.chwl.core.support.listener.SafeListenerOwner
import com.chwl.core.support.room.RoomAbility
import com.chwl.core.support.room.RoomContext
import com.chwl.library.utils.ResUtil
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum
@@ -51,6 +53,17 @@ class GameMessageAbility(private val listenerOwner: ListenerOwner<GameMessageAbi
val imEngineAbility =
context.findAbility<GameIMEngineAbility>(GameIMEngineAbility::class.java.simpleName)
imEngineAbility?.addListener(this)
addSystemNotify()
}
private fun addSystemNotify() {
val message = ChatRoomMessageBuilder.createTipMessage(
roomContext?.roomId?.toString() ?: ""
)
message.content = ResUtil.getString(
R.string.yizhuan_xchat_android_constants_xchatconstants_01
)
addMessage(message)
}
override fun onStop(context: RoomContext) {

View File

@@ -6,10 +6,8 @@ import android.view.View
import android.view.ViewTreeObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import com.chwl.app.R
import com.chwl.app.avroom.game.AppConfig
import com.chwl.app.game.core.GameQueueAbility
import com.chwl.core.auth.AuthModel
import com.chwl.core.room.game.GameModel
import com.chwl.core.room.game.bean.GameCfg
@@ -25,7 +23,6 @@ import com.chwl.library.language.LanguageHelper
import com.chwl.library.utils.SingleToastUtil
import com.chwl.library.utils.json.JsonUtils
import com.example.lib_utils.log.ILog
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import tech.sud.mgp.core.ISudFSMStateHandle
import tech.sud.mgp.core.ISudListenerInitSDK

View File

@@ -75,10 +75,19 @@ class GameMessageAdapter(val dataList: MutableList<Any>) :
if (item is ChatRoomMessage) {
if (item.msgType == MsgTypeEnum.text) {
convertText(viewHolder, item)
} else if (item.msgType == MsgTypeEnum.tip) {
convertTips(viewHolder, item)
}
}
}
private fun convertTips(holder: GameMessageNormalViewHolder, message: ChatRoomMessage) {
val textView = holder.textView
textView.setTextColor(ContextCompat.getColor(textView.context, R.color.color_white))
textView.text = message.content
textView.setBackgroundResource(R.drawable.shape_room_message_tip_bg)
}
private fun convertText(holder: GameMessageNormalViewHolder, message: ChatRoomMessage) {
val textView = holder.textView
val text = TextSpannableBuilder(textView)