2025-10-20 10:16:44 +08:00
|
|
|
package com.xscm.moduleutil.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.TextView;
|
|
|
|
|
|
|
|
|
|
import com.xscm.moduleutil.R;
|
|
|
|
|
import com.xscm.moduleutil.bean.UserInfo;
|
|
|
|
|
import com.xscm.moduleutil.bean.room.RoomPitBean;
|
|
|
|
|
import com.xscm.moduleutil.utils.ImageUtils;
|
|
|
|
|
import com.xscm.moduleutil.utils.SpUtil;
|
|
|
|
|
/**
|
|
|
|
|
*@author qx
|
|
|
|
|
*@data 2025/8/13
|
|
|
|
|
*@description: K歌模式下的视图
|
|
|
|
|
*/
|
|
|
|
|
public class RoomKtvWheatView extends BaseWheatView {
|
|
|
|
|
public ImageView mIvTagBoss;
|
|
|
|
|
public TextView mTvTime;
|
|
|
|
|
public TextView tv_time_pk;
|
|
|
|
|
|
|
|
|
|
private boolean showBoss;//显示老板标识
|
|
|
|
|
|
|
|
|
|
public RoomKtvWheatView(Context context) {
|
|
|
|
|
this(context, null, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RoomKtvWheatView(Context context, AttributeSet attrs) {
|
|
|
|
|
this(context, attrs, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RoomKtvWheatView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
|
|
|
super(context, attrs, defStyleAttr);
|
|
|
|
|
}
|
2025-10-24 17:52:11 +08:00
|
|
|
private onCharmClickListener mOnCharmClickListener;
|
2025-10-20 10:16:44 +08:00
|
|
|
|
2025-10-24 17:52:11 +08:00
|
|
|
public void setmOnCharmClickListener(onCharmClickListener mOnCharmClickListener) {
|
|
|
|
|
this.mOnCharmClickListener = mOnCharmClickListener;
|
|
|
|
|
}
|
|
|
|
|
public interface onCharmClickListener{
|
|
|
|
|
void onCharmClick(RoomKtvWheatView view, RoomPitBean pitBean);
|
|
|
|
|
}
|
2025-10-20 10:16:44 +08:00
|
|
|
@Override
|
|
|
|
|
protected void initPit(Context context, AttributeSet attrs) {
|
|
|
|
|
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoomDefaultWheatView);
|
|
|
|
|
pitNumber = typedArray.getString(R.styleable.RoomDefaultWheatView_room_wheat_number);
|
|
|
|
|
typedArray.recycle();
|
|
|
|
|
mIvTagBoss = findViewById(R.id.iv_tag_boos);
|
|
|
|
|
mTvTime = findViewById(R.id.tv_time);
|
|
|
|
|
tv_time_pk = findViewById(R.id.tv_time_pk);
|
2025-10-24 17:52:11 +08:00
|
|
|
|
|
|
|
|
mCharmView.setOnClickListener(new OnClickListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
if (mOnCharmClickListener != null && pitBean != null){
|
|
|
|
|
mOnCharmClickListener.onCharmClick(RoomKtvWheatView.this, pitBean);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-10-20 10:16:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected int getLayoutId() {
|
|
|
|
|
return R.layout.room_view_ktv_wheat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void setPitData(RoomPitBean bean) {
|
|
|
|
|
sex = bean.getSex();
|
|
|
|
|
if (isOn()) {
|
|
|
|
|
//开启声浪
|
2025-10-24 17:52:11 +08:00
|
|
|
mIvRipple.stopAnimation(true);
|
2025-10-20 10:16:44 +08:00
|
|
|
mIvRipple.setVisibility(VISIBLE);
|
|
|
|
|
mTvName.setText(bean.getNickname());
|
|
|
|
|
ImageUtils.loadHeadCC(bean.getAvatar(), mRiv);
|
|
|
|
|
if (TextUtils.isEmpty(pitBean.getDress())) {
|
2025-10-24 17:52:11 +08:00
|
|
|
mIvFrame.stopAll();
|
2025-10-20 10:16:44 +08:00
|
|
|
mIvFrame.setVisibility(INVISIBLE);
|
|
|
|
|
} else {
|
|
|
|
|
mIvFrame.setVisibility(VISIBLE);
|
2025-10-24 17:52:11 +08:00
|
|
|
mIvFrame.setSource(pitBean.getDress(), 3);
|
2025-10-20 10:16:44 +08:00
|
|
|
// ImageUtils.loadDecorationAvatar(pitBean.getDress_picture(), mIvFrame);
|
|
|
|
|
}
|
|
|
|
|
if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
|
|
|
|
mIvTagBoss.setVisibility(GONE);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
mTvName.setText(
|
|
|
|
|
"-1".equals(pitNumber) ? "" :
|
|
|
|
|
"9".equals(pitNumber) ? "主持位" :
|
|
|
|
|
"10".equals(pitNumber) ? "嘉宾位" :
|
|
|
|
|
pitNumber + "号麦位"
|
|
|
|
|
);
|
|
|
|
|
//麦位上锁
|
|
|
|
|
if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
|
|
|
|
mIvTagBoss.setVisibility(VISIBLE);
|
|
|
|
|
ImageUtils.loadRes(isLocked() ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.room_ic_wheat_default, mRiv);
|
|
|
|
|
} else {
|
|
|
|
|
// mIvTagBoss.setVisibility(GONE);
|
|
|
|
|
// @DrawableRes int origin = getOriginImage();
|
|
|
|
|
// ImageUtils.loadRes(isLocked() ? R.mipmap.room_ic_wheat_default_suo :
|
|
|
|
|
// (origin == 0 ? R.mipmap.room_ic_wheat_default : origin), mRiv);
|
|
|
|
|
mRiv.setImageResource(bean.getIs_lock() == 1 ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.room_ic_wheat_default);
|
|
|
|
|
// ImageUtils.loadRes(isLocked() ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.room_ic_wheat_default, mRiv);
|
|
|
|
|
}
|
|
|
|
|
if (isMute()) {
|
|
|
|
|
ImageUtils.loadRes(R.mipmap.room_microphone_off, mIvSex);
|
|
|
|
|
}
|
2025-10-24 17:52:11 +08:00
|
|
|
mIvFrame.stopAll();
|
2025-10-20 10:16:44 +08:00
|
|
|
mIvFrame.setVisibility(INVISIBLE);
|
|
|
|
|
mIvFace.remove();
|
|
|
|
|
//停止声浪
|
2025-10-24 17:52:11 +08:00
|
|
|
mIvRipple.stopAnimation(true);
|
2025-10-20 10:16:44 +08:00
|
|
|
mIvRipple.setVisibility(GONE);
|
|
|
|
|
}
|
|
|
|
|
if (showSexIcon) {
|
|
|
|
|
checkSex();
|
|
|
|
|
}
|
|
|
|
|
if (pitBean.getNickname() == null || pitBean.getNickname().isEmpty()) {
|
|
|
|
|
mCharmView.setVisibility(GONE);
|
|
|
|
|
} else {
|
|
|
|
|
mCharmView.setVisibility(VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pitBean.is_pk() ){
|
|
|
|
|
if (pitBean.getUser_id()!=null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
|
|
|
|
tv_time_pk.setVisibility(VISIBLE);
|
|
|
|
|
setSex(pitBean.getCharm(),false);
|
|
|
|
|
mCharmView.setVisibility(GONE);
|
|
|
|
|
}else {
|
|
|
|
|
tv_time_pk.setVisibility(GONE);
|
|
|
|
|
}
|
|
|
|
|
// ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mCharmView.getLayoutParams();
|
|
|
|
|
// params.width = 35;
|
|
|
|
|
// mCharmView.setLayoutParams(params);
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
tv_time_pk.setVisibility(GONE);
|
|
|
|
|
mCharmView.setVisibility(VISIBLE);
|
|
|
|
|
// ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mCharmView.getLayoutParams();
|
|
|
|
|
// params.width = 52;
|
|
|
|
|
// mCharmView.setLayoutParams(params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// setCardiac(pitBean.getPit_number(), 0.0f);
|
|
|
|
|
}
|
|
|
|
|
public void setSex( String value, boolean format) {
|
|
|
|
|
if (format) {
|
|
|
|
|
tv_time_pk.setText(value);
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
long xd = Long.parseLong(value);
|
|
|
|
|
if (xd > 9999 || xd < -9999) {
|
|
|
|
|
tv_time_pk.setText(String.format("%.2fw", xd / 10000.0f));
|
|
|
|
|
// mBinding.tvValue.setText(String.valueOf(xd));
|
|
|
|
|
} else {
|
|
|
|
|
tv_time_pk.setText(value);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean showSexIcon = false;
|
|
|
|
|
private String sex;
|
|
|
|
|
|
|
|
|
|
public boolean isMale() {
|
|
|
|
|
return "1".equals(sex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isFemale() {
|
|
|
|
|
return "2".equals(sex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setShowSexIcon(boolean show) {
|
|
|
|
|
showSexIcon = show;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void checkSex() {
|
|
|
|
|
if (isOn()) {
|
|
|
|
|
mIvSex.setVisibility(VISIBLE);
|
|
|
|
|
if (!TextUtils.isEmpty(sex)) {
|
|
|
|
|
if (UserInfo.MALE.equals(sex)) {
|
|
|
|
|
mIvSex.setBackgroundResource(R.drawable.room_xq_wheat_male_mask);
|
|
|
|
|
if (mTvNo != null) mTvNo.setBackgroundResource(R.mipmap.ic_room_xq_wno_male);
|
|
|
|
|
} else {
|
|
|
|
|
mIvSex.setBackgroundResource(R.drawable.room_xq_wheat_female_mask);
|
|
|
|
|
if (mTvNo != null) mTvNo.setBackgroundResource(R.mipmap.ic_room_xq_wno_female);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
mIvSex.setVisibility(GONE);
|
|
|
|
|
if (mTvNo != null) mTvNo.setBackgroundResource(getOriginNoImage());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
mIvSex.setVisibility(GONE);
|
|
|
|
|
if (mTvNo != null) mTvNo.setBackgroundResource(getOriginNoImage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 是否显示老板标识
|
|
|
|
|
*/
|
|
|
|
|
public void setIsBossShow(String is_boss_pit) {
|
|
|
|
|
showBoss = "1".equals(is_boss_pit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 开启计时
|
|
|
|
|
*/
|
|
|
|
|
public void setTime(int time) {
|
|
|
|
|
if (time == 0) {
|
|
|
|
|
mTvTime.setText("");
|
|
|
|
|
mTvTime.setVisibility(INVISIBLE);
|
|
|
|
|
} else {
|
|
|
|
|
mTvTime.setText(String.format("%s'%s", time / 60, time % 60));
|
|
|
|
|
mTvTime.setVisibility(VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void hideMaoziIcon() {
|
|
|
|
|
View maozi = findViewById(R.id.iv_maozi);
|
|
|
|
|
if (maozi != null) maozi.setVisibility(GONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onRemoteSoundLevelUpdate(String userId, int soundLevel) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onLocalSoundLevelUpdate(int volume) {
|
|
|
|
|
if (volume==0){
|
2025-10-24 17:52:11 +08:00
|
|
|
mIvRipple.stopAnimation(true);
|
2025-10-20 10:16:44 +08:00
|
|
|
} else {
|
|
|
|
|
if (pitBean.getUser_id().equals(SpUtil.getUserId()) && closePhone) {
|
2025-10-24 17:52:11 +08:00
|
|
|
mIvRipple.stopAnimation(true);
|
2025-10-20 10:16:44 +08:00
|
|
|
}else {
|
|
|
|
|
mIvRipple.post(() -> {
|
|
|
|
|
if (!mIvRipple.isAnimating()) {
|
|
|
|
|
mIvRipple.startAnimation();
|
|
|
|
|
}
|
|
|
|
|
mIvRipple.setVisibility(VISIBLE);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void userJoined(int userId, int elapsd) {
|
|
|
|
|
if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) {
|
|
|
|
|
if (pitBean.getUser_id().equals(userId + "")) {
|
2025-10-24 17:52:11 +08:00
|
|
|
// iv_on_line.setVisibility(GONE);
|
2025-10-20 10:16:44 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void userOffline(int userId, int reason) {
|
|
|
|
|
if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) {
|
|
|
|
|
if (pitBean.getUser_id().equals(userId + "")) {
|
2025-10-24 17:52:11 +08:00
|
|
|
// iv_on_line.setVisibility(VISIBLE);
|
2025-10-20 10:16:44 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-18 18:28:16 +08:00
|
|
|
@Override
|
|
|
|
|
public void pkOffSide(int uid) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-24 17:52:11 +08:00
|
|
|
@Override
|
|
|
|
|
public void unRegister(Object obj) {
|
|
|
|
|
|
|
|
|
|
}
|
2025-10-20 10:16:44 +08:00
|
|
|
}
|