1:羽声新版本

This commit is contained in:
2025-10-24 17:52:11 +08:00
parent 437a623f81
commit a809b02ebb
827 changed files with 25795 additions and 1193698 deletions

View File

@@ -23,7 +23,7 @@ public class RoomSingSongWheatView extends BaseWheatView {
public ImageView mIvTagBoss;
public TextView mTvTime;
public TextView tv_time_pk;
public boolean isClickListenerSet = false;
private boolean showBoss;//显示老板标识
public RoomSingSongWheatView(Context context) {
@@ -40,9 +40,15 @@ public class RoomSingSongWheatView extends BaseWheatView {
@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();
TypedArray typedArray = null;
try {
typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoomDefaultWheatView);
pitNumber = typedArray.getString(R.styleable.RoomDefaultWheatView_room_wheat_number);
} finally {
if (typedArray != null) {
typedArray.recycle();
}
}
mIvTagBoss = findViewById(R.id.iv_tag_boos);
mTvTime = findViewById(R.id.tv_time);
tv_time_pk = findViewById(R.id.tv_time_pk);
@@ -55,83 +61,101 @@ public class RoomSingSongWheatView extends BaseWheatView {
@Override
protected void setPitData(RoomPitBean bean) {
if (bean == null) return;
sex = bean.getSex();
pitBean = bean; // 统一使用参数 bean
stopAndClearAnimation(); // 清理之前的动画资源
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);
}
handleOnState(bean);
} 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);
handleOffState(bean);
}
updateSexIcon();
// updateCharmViewVisibility(bean);
updatePkState(bean);
iv_on_line.setVisibility(GONE);
}
private void handleOnState(RoomPitBean bean) {
mIvRipple.setVisibility(VISIBLE);
mTvName.setText(bean.getNickname());
ImageUtils.loadHeadCC(bean.getAvatar(), mRiv);
mCharmView.setVisibility(VISIBLE);
if (TextUtils.isEmpty(bean.getDress())) {
mIvFrame.stopAll();
mIvFrame.setVisibility(INVISIBLE);
} else {
mIvFrame.setVisibility(VISIBLE);
mIvFrame.setSource(bean.getDress(), 3);
}
if (showBoss && TextUtils.equals(WHEAT_BOSS, pitNumber)) {
mIvTagBoss.setVisibility(GONE);
}
}
private void handleOffState(RoomPitBean bean) {
mTvName.setText(getPitNumberText());
mCharmView.setVisibility(GONE);
if (showBoss && TextUtils.equals(WHEAT_BOSS, pitNumber)) {
mIvTagBoss.setVisibility(VISIBLE);
int resId = bean.getIs_lock() == 1 ? R.mipmap.index_img_room_mask : R.drawable.room_ic_wheat_default;
mRiv.setImageResource(resId);
} else {
mRiv.setImageResource(bean.getIs_lock() == 1 ? R.mipmap.index_img_room_mask : R.drawable.room_ic_wheat_default);
}
if (isMute()) {
ImageUtils.loadRes(R.mipmap.room_microphone_off, mIvSex);
}
mIvFrame.stopAll();
mIvFrame.setVisibility(INVISIBLE);
mIvFace.remove();
mIvRipple.setVisibility(GONE);
}
private String getPitNumberText() {
if ("-1".equals(pitNumber)) return "";
if ("9".equals(pitNumber)) return "主持位";
if ("10".equals(pitNumber)) return "嘉宾位";
return pitNumber + "号麦位";
}
private void updateSexIcon() {
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()) {
private void updateCharmViewVisibility(RoomPitBean bean) {
boolean isEmptyNickname = bean.getNickname() == null || bean.getNickname().isEmpty();
mCharmView.setVisibility(isEmptyNickname ? GONE : VISIBLE);
}
private void updatePkState(RoomPitBean bean) {
if (bean.is_pk()) {
String userId = bean.getUser_id();
if (userId != null && !userId.equals("0") && !userId.isEmpty()) {
tv_time_pk.setVisibility(VISIBLE);
setSex(pitBean.getCharm(),false);
setSex(bean.getCharm(), false);
mCharmView.setVisibility(GONE);
}else {
} else {
tv_time_pk.setVisibility(GONE);
}
// ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mCharmView.getLayoutParams();
// params.width = 35;
// mCharmView.setLayoutParams(params);
}else {
} else {
tv_time_pk.setVisibility(GONE);
mCharmView.setVisibility(VISIBLE);
// ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mCharmView.getLayoutParams();
// params.width = 52;
// mCharmView.setLayoutParams(params);
if (isOn()) {
mCharmView.setVisibility(VISIBLE);
}else {
mCharmView.setVisibility(GONE);
}
}
// setCardiac(pitBean.getPit_number(), 0.0f);
}
public void setSex( String value, boolean format) {
public void setSex(String value, boolean format) {
if (format) {
tv_time_pk.setText(value);
} else {
@@ -139,12 +163,12 @@ public class RoomSingSongWheatView extends BaseWheatView {
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();
tv_time_pk.setText("0"); // 设置默认值防止UI异常
}
}
}
@@ -210,25 +234,75 @@ public class RoomSingSongWheatView extends BaseWheatView {
if (maozi != null) maozi.setVisibility(GONE);
}
// 添加内存释放方法
public void releaseResources() {
stopAndClearAnimation();
// 清理头像加载
if (mRiv != null) {
mRiv.setImageBitmap(null);
}
// 清理框架视图
if (mIvFrame != null) {
mIvFrame.release(); // 清理SVGA资源
}
// 清理表情视图
if (mIvFace != null) {
mIvFace.remove();
}
// 清理其他图片资源
if (mIvSex != null) {
mIvSex.setImageBitmap(null);
}
if (mIvTagBoss != null) {
mIvTagBoss.setImageBitmap(null);
}
}
// 停止并清理动画资源
private void stopAndClearAnimation() {
if (mIvRipple != null) {
// mIvRipple.stopAnimation();
mIvRipple.stopAnimation(true);
// 清理SVGA资源避免内存泄漏
// mIvRipple.clear();
}
}
@Override
protected void onDetachedFromWindow() {
// 视图从窗口分离时释放资源
releaseResources();
super.onDetachedFromWindow();
}
@Override
public void onRemoteSoundLevelUpdate(String userId, int soundLevel) {
// 暂无实现
}
@Override
public void onLocalSoundLevelUpdate(int volume) {
if (volume==0){
mIvRipple.stopAnimation();
if (mIvRipple == null) {
return;
}
if (volume == 0) {
mIvRipple.setVisibility(GONE);
mIvRipple.stopAnimation(true);
} else {
if (pitBean.getUser_id().equals(SpUtil.getUserId()) && closePhone) {
mIvRipple.stopAnimation();
}else {
// 增加空指针检查
if (pitBean != null && pitBean.getUser_id() != null &&
pitBean.getUser_id().equals(SpUtil.getUserId()) && closePhone) {
mIvRipple.stopAnimation(true);
} else {
mIvRipple.post(() -> {
if (!mIvRipple.isAnimating()) {
mIvRipple.startAnimation();
}
mIvRipple.setVisibility(VISIBLE);
mIvRipple.startAnimation();
});
}
}
@@ -236,12 +310,16 @@ public class RoomSingSongWheatView extends BaseWheatView {
@Override
public void userJoined(int userId, int elapsd) {
// 暂无实现
}
@Override
public void userOffline(int userId, int reason) {
// 暂无实现
}
@Override
public void unRegister(Object obj) {
}
}