2026-01-05 15:43:25 +08:00
|
|
|
package com.xscm.modulemain.widget
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import android.content.res.TypedArray
|
|
|
|
|
import android.text.TextUtils
|
|
|
|
|
import android.util.AttributeSet
|
|
|
|
|
import android.view.View
|
|
|
|
|
import android.widget.ImageView
|
|
|
|
|
import android.widget.LinearLayout
|
|
|
|
|
import android.widget.TextView
|
|
|
|
|
import com.xscm.modulemain.R
|
|
|
|
|
import com.xscm.moduleutil.bean.room.RoomPitBean
|
|
|
|
|
import com.xscm.moduleutil.utils.ImageUtils
|
2026-01-07 19:19:28 +08:00
|
|
|
import com.xscm.moduleutil.utils.SpUtil
|
2026-01-07 09:01:59 +08:00
|
|
|
import com.xscm.moduleutil.widget.AvatarFrameView
|
2026-01-05 15:43:25 +08:00
|
|
|
import com.xscm.moduleutil.widget.BaseWheatView
|
|
|
|
|
|
|
|
|
|
class RoomPubWheatView : BaseWheatView {
|
|
|
|
|
constructor(context: Context?) : super(context)
|
|
|
|
|
|
|
|
|
|
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
|
|
|
|
context,
|
|
|
|
|
attrs,
|
|
|
|
|
defStyleAttr
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var iv_tag_type: ImageView? = null
|
|
|
|
|
var iv_custom_gift: ImageView? = null
|
|
|
|
|
private var hostTv: TextView? = null
|
|
|
|
|
private var tv_time: TextView? = null
|
|
|
|
|
private var ll_bottom: LinearLayout? = null
|
2026-01-07 19:25:34 +08:00
|
|
|
private var iv_gift: AvatarFrameView? = null
|
2026-01-05 15:43:25 +08:00
|
|
|
var ivYueT: ImageView? = null
|
|
|
|
|
var ivLiaoT: ImageView? = null
|
|
|
|
|
|
2026-01-07 19:25:34 +08:00
|
|
|
|
2026-01-05 15:43:25 +08:00
|
|
|
override fun initPit(context: Context, attrs: AttributeSet) {
|
|
|
|
|
var typedArray: TypedArray? = null
|
|
|
|
|
try {
|
|
|
|
|
typedArray = context.obtainStyledAttributes(
|
|
|
|
|
attrs,
|
|
|
|
|
com.xscm.moduleutil.R.styleable.RoomDefaultWheatView
|
|
|
|
|
)
|
|
|
|
|
pitNumber =
|
|
|
|
|
typedArray.getString(com.xscm.moduleutil.R.styleable.RoomDefaultWheatView_room_wheat_number)
|
|
|
|
|
} finally {
|
|
|
|
|
typedArray?.recycle()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mCharmView = findViewById(R.id.charm_view)
|
|
|
|
|
mIvRipple = findViewById(R.id.iv_ripple)
|
|
|
|
|
mIvFrame = findViewById(R.id.iv_frame)
|
|
|
|
|
mIvShutup = findViewById(R.id.iv_shutup)
|
|
|
|
|
mRiv = findViewById(R.id.riv)
|
|
|
|
|
iv_tag_type = findViewById(R.id.iv_tag_type)
|
|
|
|
|
ll_bottom = findViewById(R.id.ll_bottom)
|
|
|
|
|
iv_custom_gift = findViewById(R.id.iv_custom_gift)
|
|
|
|
|
tv_time = findViewById(R.id.tv_time)
|
|
|
|
|
|
|
|
|
|
ivYueT = findViewById(R.id.iv_yue_t)
|
|
|
|
|
ivLiaoT = findViewById(R.id.iv_liao_t)
|
2026-01-07 09:01:59 +08:00
|
|
|
iv_gift = findViewById(R.id.iv_gift)
|
2026-01-05 15:43:25 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun getLayoutId(): Int {
|
|
|
|
|
return R.layout.layout_room_pub_wheat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 提供一个方法来设置这个属性,便于在代码中动态更改
|
|
|
|
|
fun setRoomWheatNumber(number: String?) {
|
|
|
|
|
this.pitNumber = number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override fun setPitData(bean: RoomPitBean) {
|
|
|
|
|
pitBean = bean // 统一使用参数 bean
|
|
|
|
|
stopAndClearAnimation() // 清理之前的动画资源
|
|
|
|
|
when (bean.pit_number) {
|
|
|
|
|
"9" -> {
|
|
|
|
|
iv_tag_type?.visibility = View.VISIBLE
|
|
|
|
|
iv_tag_type?.setImageResource(com.xscm.moduleutil.R.mipmap.zc)
|
2026-01-08 17:02:29 +08:00
|
|
|
tv_time?.visibility = View.INVISIBLE
|
|
|
|
|
ll_bottom?.visibility = View.INVISIBLE
|
2026-01-05 15:43:25 +08:00
|
|
|
iv_custom_gift?.visibility = View.GONE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"10" -> {
|
|
|
|
|
iv_tag_type?.visibility = View.VISIBLE
|
|
|
|
|
iv_tag_type?.setImageResource(com.xscm.moduleutil.R.mipmap.jb)
|
2026-01-08 17:02:29 +08:00
|
|
|
tv_time?.visibility = View.INVISIBLE
|
|
|
|
|
ll_bottom?.visibility = View.INVISIBLE
|
2026-01-05 15:43:25 +08:00
|
|
|
iv_custom_gift?.visibility = View.GONE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else -> {
|
2026-01-07 18:03:16 +08:00
|
|
|
tv_time?.visibility = View.INVISIBLE
|
2026-01-07 19:25:34 +08:00
|
|
|
ll_bottom?.visibility = View.INVISIBLE
|
2026-01-05 15:43:25 +08:00
|
|
|
iv_custom_gift?.visibility = View.GONE
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mCharmView.visibility = View.GONE
|
|
|
|
|
|
|
|
|
|
if (isOn) {
|
|
|
|
|
handleOnState(bean)
|
|
|
|
|
} else {
|
|
|
|
|
handleOffState(bean)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun setSex(value: String?, format: Boolean) {
|
|
|
|
|
mCharmView.setSex("", "", value, format)
|
|
|
|
|
}
|
2026-01-07 19:25:34 +08:00
|
|
|
fun setPitGift(giftPlayString: String){
|
|
|
|
|
iv_gift?.visibility=VISIBLE
|
|
|
|
|
iv_gift?.setSource(giftPlayString, 2)
|
2026-01-07 09:01:59 +08:00
|
|
|
}
|
2026-01-05 15:43:25 +08:00
|
|
|
|
2026-01-08 15:36:17 +08:00
|
|
|
fun setIvCustomGift(boolean: Boolean){
|
|
|
|
|
iv_custom_gift?.visibility = if (boolean) View.VISIBLE else View.GONE
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-05 15:43:25 +08:00
|
|
|
private fun handleOnState(bean: RoomPitBean) {
|
|
|
|
|
mIvRipple.visibility = VISIBLE
|
|
|
|
|
mTvName.text = bean.nickname
|
|
|
|
|
ImageUtils.loadHeadCC(bean.avatar, mRiv)
|
|
|
|
|
|
|
|
|
|
if (!bean.pit_number.equals("9") && !bean.pit_number.equals("10")) {
|
|
|
|
|
tv_time?.visibility = View.VISIBLE
|
2026-01-07 19:19:28 +08:00
|
|
|
if (bean.user_id != SpUtil.getUserId().toString()) {
|
|
|
|
|
if (bean.had_custom_gift==1){
|
|
|
|
|
iv_custom_gift?.visibility = View.VISIBLE
|
|
|
|
|
}
|
|
|
|
|
ll_bottom?.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
|
|
}
|
2026-01-07 18:03:16 +08:00
|
|
|
tv_time?.text = "00:00"
|
2026-01-05 15:43:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(bean.dress)) {
|
|
|
|
|
mIvFrame.stopAll()
|
|
|
|
|
mIvFrame.visibility = INVISIBLE
|
|
|
|
|
} else {
|
|
|
|
|
mIvFrame.visibility = VISIBLE
|
|
|
|
|
mIvFrame.setSource(bean.dress, 3)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val pitNumberText: String
|
|
|
|
|
get() {
|
2026-01-07 19:25:34 +08:00
|
|
|
return pitNumber+"号麦"
|
2026-01-05 15:43:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun handleOffState(bean: RoomPitBean) {
|
|
|
|
|
mTvName.text = pitNumberText
|
|
|
|
|
mRiv.visibility = VISIBLE
|
|
|
|
|
mRiv.setImageResource(com.xscm.moduleutil.R.mipmap.room_ic_wheat_default)
|
|
|
|
|
mIvShutup.visibility = GONE
|
|
|
|
|
iv_tag_type!!.visibility = GONE
|
|
|
|
|
mIvFrame.stopAll()
|
|
|
|
|
mIvFrame.visibility = GONE
|
|
|
|
|
mIvRipple.visibility = GONE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun stopAndClearAnimation() {
|
|
|
|
|
if (mIvRipple != null) {
|
|
|
|
|
mIvRipple.stopAnimation(true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onRemoteSoundLevelUpdate(userId: String, soundLevel: Int) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onLocalSoundLevelUpdate(volume: Int) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun userJoined(userId: Int, elapsd: Int) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun userOffline(userId: Int, reason: Int) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun pkOffSide(userId: Int) {
|
|
|
|
|
}
|
|
|
|
|
}
|