签约房UI
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
package com.xscm.modulemain.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.TypedArray
|
||||
import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import com.xscm.modulemain.R
|
||||
import com.xscm.moduleutil.bean.room.RoomPitBean
|
||||
import com.xscm.moduleutil.utils.ImageUtils
|
||||
import com.xscm.moduleutil.widget.BaseWheatView
|
||||
|
||||
class RoomMentorShipWheatView(context: Context?) : BaseWheatView(context) {
|
||||
|
||||
constructor(context: Context?, attrs: AttributeSet?) : this(context) {
|
||||
initPit(context, attrs)
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.layout_room_mentorship_wheat
|
||||
}
|
||||
|
||||
// 提供一个方法来设置这个属性,便于在代码中动态更改
|
||||
fun setRoomWheatNumber(number: String?) {
|
||||
this.pitNumber = number
|
||||
}
|
||||
|
||||
override fun setPitData(bean: RoomPitBean?) {
|
||||
if (bean == null) return
|
||||
|
||||
pitBean = bean // 统一使用参数 bean
|
||||
stopAndClearAnimation() // 清理之前的动画资源
|
||||
|
||||
if (isOn) {
|
||||
handleOnState(bean)
|
||||
} else {
|
||||
handleOffState(bean)
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopAndClearAnimation() {
|
||||
if (mIvRipple != null) {
|
||||
mIvRipple.stopAnimation(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun handleOnState(bean: RoomPitBean) {
|
||||
mIvRipple.visibility = VISIBLE
|
||||
mTvName.visibility = VISIBLE
|
||||
mTvName.text = bean.nickname
|
||||
ImageUtils.loadHeadCC(bean.avatar, mRiv)
|
||||
mCharmView.visibility = VISIBLE
|
||||
if (TextUtils.isEmpty(bean.dress)) {
|
||||
mIvFrame.stopAll()
|
||||
mIvFrame.visibility = INVISIBLE
|
||||
} else {
|
||||
mIvFrame.visibility = VISIBLE
|
||||
mIvFrame.setSource(bean.dress, 3)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleOffState(bean: RoomPitBean) {
|
||||
if (bean.pit_number == "9") {
|
||||
mTvName.visibility = GONE
|
||||
} else {
|
||||
mTvName.visibility = VISIBLE
|
||||
mTvName.setText(getPitNumberText())
|
||||
}
|
||||
mCharmView.visibility = GONE
|
||||
mRiv.visibility = VISIBLE
|
||||
mRiv.setImageResource(R.mipmap.jukebox_room_mask)
|
||||
mIvShutup.visibility = GONE
|
||||
mIvFrame.stopAll()
|
||||
mIvFrame.visibility = GONE
|
||||
mIvRipple.visibility = GONE
|
||||
}
|
||||
|
||||
|
||||
private fun getPitNumberText(): String {
|
||||
if ("-1" == pitNumber) return ""
|
||||
if ("9" == pitNumber) return ""
|
||||
if ("10" == pitNumber) return "老板"
|
||||
return pitNumber + "号麦"
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user