2025-08-26 19:34:44 +08:00
|
|
|
|
package com.xscm.moduleutil.widget;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
import android.content.res.TypedArray;
|
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
|
|
import android.view.View;
|
|
|
|
|
|
import android.widget.ImageView;
|
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
|
|
|
|
import androidx.constraintlayout.widget.ConstraintSet;
|
|
|
|
|
|
|
|
|
|
|
|
import com.xscm.moduleutil.R;
|
|
|
|
|
|
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
|
|
|
|
|
import com.xscm.moduleutil.bean.room.RoomPitBean;
|
|
|
|
|
|
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
|
|
|
|
|
import com.xscm.moduleutil.utils.ImageUtils;
|
|
|
|
|
|
|
|
|
|
|
|
public class RoomFriendshipWheatView extends BaseWheatView {
|
|
|
|
|
|
|
|
|
|
|
|
public ImageView mIvTagBoss;
|
|
|
|
|
|
public TextView mTvTime;
|
|
|
|
|
|
public ImageView iv_on_line;
|
|
|
|
|
|
private ImageView iv_tag_type;
|
|
|
|
|
|
public WheatCharmView mCharmView;
|
|
|
|
|
|
public TextView tv_zhul;
|
|
|
|
|
|
|
|
|
|
|
|
private boolean showBoss;//显示老板标识
|
|
|
|
|
|
private boolean showSexIcon = false;
|
|
|
|
|
|
private String sex;
|
|
|
|
|
|
|
|
|
|
|
|
public RoomFriendshipWheatView(Context context, AttributeSet attrs) {
|
|
|
|
|
|
super(context, attrs);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public RoomFriendshipWheatView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
|
|
|
|
super(context, attrs, defStyleAttr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public RoomFriendshipWheatView(Context context) {
|
|
|
|
|
|
super(context);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void initPit(Context context, AttributeSet attrs) {
|
|
|
|
|
|
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoomMakeWheatView);
|
|
|
|
|
|
pitNumber = typedArray.getString(R.styleable.RoomMakeWheatView_room_make_wheat_number);
|
|
|
|
|
|
pitImageVId = typedArray.getResourceId(R.styleable.RoomMakeWheatView_room_make_pic, 0);
|
|
|
|
|
|
typedArray.recycle();
|
|
|
|
|
|
mIvTagBoss = findViewById(R.id.iv_tag_boos);
|
|
|
|
|
|
mTvTime = findViewById(R.id.tv_time);
|
|
|
|
|
|
iv_on_line = findViewById(R.id.iv_online);
|
|
|
|
|
|
iv_tag_type = findViewById(R.id.iv_tag_type);
|
|
|
|
|
|
mCharmView = findViewById(R.id.charm_view);
|
|
|
|
|
|
mRiv.setImageResource(pitImageVId);
|
|
|
|
|
|
tv_zhul = findViewById(R.id.tv_zhul);
|
|
|
|
|
|
|
|
|
|
|
|
// 为 tv_zhul 设置点击监听
|
|
|
|
|
|
if (tv_zhul != null) {
|
|
|
|
|
|
tv_zhul.setOnClickListener(new OnClickListener() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
if (mOnZhulClickListener != null && pitBean != null) {
|
|
|
|
|
|
mOnZhulClickListener.onZhulClick(RoomFriendshipWheatView.this, pitBean);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected int getLayoutId() {
|
|
|
|
|
|
return R.layout.room_view_friendship_wheat;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void setPitData(RoomPitBean bean) {
|
|
|
|
|
|
sex = bean.getSex();
|
|
|
|
|
|
if (isOn()) {
|
|
|
|
|
|
//开启声浪
|
2025-09-04 01:10:07 +08:00
|
|
|
|
mIvRipple.stopAnimation(true);
|
2025-08-26 19:34:44 +08:00
|
|
|
|
mIvRipple.setVisibility(VISIBLE);
|
|
|
|
|
|
mTvName.setText(bean.getNickname());
|
|
|
|
|
|
ImageUtils.loadCenterCrop(bean.getAvatar(), mRiv);
|
|
|
|
|
|
if (TextUtils.isEmpty(pitBean.getDress_picture())) {
|
|
|
|
|
|
mIvFrame.setVisibility(INVISIBLE);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mIvFrame.setVisibility(VISIBLE);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
|
|
|
|
|
mIvTagBoss.setVisibility(GONE);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mTvName.setText((!"10".equals(pitBean.getPit_number()) && !"9".equals(pitBean.getPit_number())) ? pitBean.getPit_number() : "");
|
|
|
|
|
|
//麦位上锁
|
|
|
|
|
|
//麦位上锁
|
|
|
|
|
|
// if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
|
|
|
|
|
// mIvTagBoss.setVisibility(VISIBLE);
|
|
|
|
|
|
// ImageUtils.loadRes(isLocked() ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.jiaoy, mRiv);
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// mRiv.setImageResource(bean.getIs_lock() == 1 ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.jiaoy);
|
|
|
|
|
|
// }
|
|
|
|
|
|
if (pitBean.getPit_number().equals("4") || pitBean.getPit_number().equals("5") || pitBean.getPit_number().equals("6")) {
|
|
|
|
|
|
ImageUtils.loadRes(R.mipmap.jiaoy_n, mRiv);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ImageUtils.loadRes(R.mipmap.jiaoy, mRiv);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isMute()) {
|
|
|
|
|
|
ImageUtils.loadRes(R.mipmap.room_microphone_off, mIvSex);
|
|
|
|
|
|
}
|
|
|
|
|
|
mIvFrame.setVisibility(INVISIBLE);
|
|
|
|
|
|
mIvFace.remove();
|
|
|
|
|
|
//停止声浪
|
2025-09-04 01:10:07 +08:00
|
|
|
|
mIvRipple.stopAnimation( true);
|
2025-08-26 19:34:44 +08:00
|
|
|
|
mIvRipple.setVisibility(GONE);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (showSexIcon) {
|
|
|
|
|
|
checkSex();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (pitBean.getPit_number().equals("9")) {
|
|
|
|
|
|
iv_tag_type.setVisibility(VISIBLE);
|
|
|
|
|
|
iv_tag_type.setImageResource(R.mipmap.zc);
|
|
|
|
|
|
switchCharmViewPosition(false);
|
|
|
|
|
|
tv_zhul.setVisibility(GONE);
|
|
|
|
|
|
} else if (pitBean.getPit_number().equals("10")) {
|
|
|
|
|
|
iv_tag_type.setVisibility(VISIBLE);
|
|
|
|
|
|
iv_tag_type.setImageResource(R.mipmap.jb);
|
|
|
|
|
|
switchCharmViewPosition(false);
|
|
|
|
|
|
tv_zhul.setVisibility(GONE);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
iv_tag_type.setVisibility(GONE);
|
|
|
|
|
|
switchCharmViewPosition(true);
|
|
|
|
|
|
// tv_zhul.setVisibility(VISIBLE);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pitBean.getPit_number().equals("1") || pitBean.getPit_number().equals("2") || pitBean.getPit_number().equals("3")) {
|
|
|
|
|
|
ThemeableDrawableUtils.setThemeableRoundedBackground(tv_zhul, Color.parseColor("#D449E4"), 53);
|
|
|
|
|
|
tv_zhul.setTextColor(Color.parseColor("#FFFFFF"));
|
|
|
|
|
|
} else if (pitBean.getPit_number().equals("4") || pitBean.getPit_number().equals("5") || pitBean.getPit_number().equals("6")) {
|
|
|
|
|
|
ThemeableDrawableUtils.setThemeableRoundedBackground(tv_zhul, Color.parseColor("#4965E4"), 53);
|
|
|
|
|
|
tv_zhul.setTextColor(Color.parseColor("#FFFFFF"));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void checkSex() {
|
|
|
|
|
|
if (isOn()) {
|
|
|
|
|
|
mIvSex.setVisibility(VISIBLE);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mIvSex.setVisibility(GONE);
|
|
|
|
|
|
if (mTvNo != null) mTvNo.setBackgroundResource(getOriginNoImage());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 切换 charm_view 的显示位置
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param showAtTagTypePosition true-显示在 iv_tag_type 位置,false-显示在原始位置
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
public void switchCharmViewPosition(boolean showAtTagTypePosition) {
|
|
|
|
|
|
if (mCharmView == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
// 确保视图已经加载完成
|
|
|
|
|
|
if (getWidth() == 0 || getHeight() == 0) {
|
|
|
|
|
|
post(() -> switchCharmViewPosition(showAtTagTypePosition));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ConstraintSet constraintSet = new ConstraintSet();
|
|
|
|
|
|
ConstraintLayout constraintLayout = (ConstraintLayout) getChildAt(0);
|
|
|
|
|
|
constraintSet.clone(constraintLayout);
|
|
|
|
|
|
|
|
|
|
|
|
if (showAtTagTypePosition) {
|
|
|
|
|
|
// 显示在 tag_type 位置(替代 tag_type 的位置)
|
|
|
|
|
|
if (iv_tag_type != null) {
|
|
|
|
|
|
iv_tag_type.setVisibility(GONE);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 清除原有约束
|
|
|
|
|
|
constraintSet.clear(R.id.charm_view, ConstraintSet.TOP);
|
|
|
|
|
|
// constraintSet.clear(R.id.charm_view, ConstraintSet.START);
|
|
|
|
|
|
// constraintSet.clear(R.id.charm_view, ConstraintSet.END);
|
|
|
|
|
|
|
|
|
|
|
|
// 设置新约束(与 iv_tag_type 相同的位置)
|
|
|
|
|
|
constraintSet.connect(
|
|
|
|
|
|
R.id.charm_view, ConstraintSet.TOP,
|
|
|
|
|
|
R.id.riv, ConstraintSet.BOTTOM,
|
|
|
|
|
|
-dip2px(12) // 与 iv_tag_type 相同的 margin
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// constraintSet.connect(
|
|
|
|
|
|
// R.id.charm_view, ConstraintSet.START,
|
|
|
|
|
|
// R.id.riv, ConstraintSet.START,
|
|
|
|
|
|
// 0
|
|
|
|
|
|
// );
|
|
|
|
|
|
//
|
|
|
|
|
|
// constraintSet.connect(
|
|
|
|
|
|
// R.id.charm_view, ConstraintSet.END,
|
|
|
|
|
|
// R.id.riv, ConstraintSet.END,
|
|
|
|
|
|
// 0
|
|
|
|
|
|
// );
|
|
|
|
|
|
mCharmView.setBg(R.drawable.room_bg_wheat_jy_charm);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 恢复原始位置(在 tv_name 下面)
|
|
|
|
|
|
// 显示 iv_tag_type(如果需要)
|
|
|
|
|
|
if (iv_tag_type != null) {
|
|
|
|
|
|
iv_tag_type.setVisibility(VISIBLE);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 清除临时约束
|
|
|
|
|
|
constraintSet.clear(R.id.charm_view, ConstraintSet.TOP);
|
|
|
|
|
|
constraintSet.clear(R.id.charm_view, ConstraintSet.START);
|
|
|
|
|
|
constraintSet.clear(R.id.charm_view, ConstraintSet.END);
|
|
|
|
|
|
|
|
|
|
|
|
// 恢复原始约束
|
|
|
|
|
|
constraintSet.connect(
|
|
|
|
|
|
R.id.charm_view, ConstraintSet.TOP,
|
|
|
|
|
|
R.id.tv_name, ConstraintSet.BOTTOM,
|
|
|
|
|
|
0
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
constraintSet.connect(
|
|
|
|
|
|
R.id.charm_view, ConstraintSet.START,
|
|
|
|
|
|
R.id.riv, ConstraintSet.START,
|
|
|
|
|
|
0
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
constraintSet.connect(
|
|
|
|
|
|
R.id.charm_view, ConstraintSet.END,
|
|
|
|
|
|
R.id.riv, ConstraintSet.END,
|
|
|
|
|
|
0
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
constraintSet.applyTo(constraintLayout);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 添加dp转px的工具方法
|
|
|
|
|
|
private int dip2px(float dpValue) {
|
|
|
|
|
|
final float scale = getContext().getResources().getDisplayMetrics().density;
|
|
|
|
|
|
return (int) (dpValue * scale + 0.5f);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 开启计时
|
|
|
|
|
|
*/
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onRemoteSoundLevelUpdate(String userId, int soundLevel) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onLocalSoundLevelUpdate(int volume) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void userJoined(int userId, int elapsd) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void userOffline(int userId, int reason) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setOnlineStatus(UserOnlineStatusBean isOnline) {
|
|
|
|
|
|
if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
|
|
|
|
|
if (pitBean.getUser_id().equals(isOnline.getUser_id())) {
|
|
|
|
|
|
if (isOnline.getIs_online() == 1) {
|
|
|
|
|
|
iv_on_line.setVisibility(GONE);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
iv_on_line.setVisibility(VISIBLE);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 设置是否显示助力按钮
|
|
|
|
|
|
public void setLockZl(boolean lock) {
|
|
|
|
|
|
tv_zhul.setVisibility(lock ? VISIBLE : INVISIBLE);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private OnZhulClickListener mOnZhulClickListener;
|
|
|
|
|
|
|
|
|
|
|
|
// 设置监听器的方法
|
|
|
|
|
|
public void setOnZhulClickListener(OnZhulClickListener listener) {
|
|
|
|
|
|
this.mOnZhulClickListener = listener;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-04 01:10:07 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void unRegister(Object obj) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-26 19:34:44 +08:00
|
|
|
|
public interface OnZhulClickListener {
|
|
|
|
|
|
void onZhulClick(RoomFriendshipWheatView view, RoomPitBean pitBean);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|