空格
This commit is contained in:
@@ -0,0 +1,254 @@
|
||||
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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_view_ktv_wheat;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPitData(RoomPitBean bean) {
|
||||
sex = bean.getSex();
|
||||
if (isOn()) {
|
||||
//开启声浪
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
mTvName.setText(bean.getNickname());
|
||||
ImageUtils.loadHeadCC(bean.getAvatar(), mRiv);
|
||||
if (TextUtils.isEmpty(pitBean.getDress())) {
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
} else {
|
||||
mIvFrame.setVisibility(VISIBLE);
|
||||
mIvFrame.setSource(pitBean.getDress(), 1);
|
||||
// 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);
|
||||
}
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
mIvFace.remove();
|
||||
//停止声浪
|
||||
mIvRipple.stopAnimation();
|
||||
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){
|
||||
mIvRipple.stopAnimation();
|
||||
} else {
|
||||
if (pitBean.getUser_id().equals(SpUtil.getUserId()) && closePhone) {
|
||||
mIvRipple.stopAnimation();
|
||||
}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 + "")) {
|
||||
iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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 + "")) {
|
||||
iv_on_line.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user