1:修改排行榜页面,

2:修改拍卖房刷新数据
3:修改交友房刷新数据
This commit is contained in:
2025-10-25 18:07:21 +08:00
parent 529aae1fcf
commit 8ebe1530ee
128 changed files with 3640 additions and 2099 deletions

View File

@@ -114,12 +114,13 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
}
QXGiftDriftView qxGiftDriftView;
protected void doDone(){}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setBackgroundResource(R.mipmap.log_bj);
setContentView(getLayoutId());
doDone();
// 隐藏标题栏
if (getSupportActionBar() != null) {
getSupportActionBar().hide();

View File

@@ -50,7 +50,10 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
protected abstract P bindPresenter();
@Override
protected void doDone() {
super.doDone();
}
@Override
protected void initView() {
@@ -75,7 +78,11 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
@Override
protected void onDestroy() {
if (MvpPre != null) {
MvpPre.detachView();
try {
MvpPre.detachView();
}catch (Exception e){
e.printStackTrace();
}
}
super.onDestroy();
}

View File

@@ -2,15 +2,21 @@ package com.xscm.moduleutil.base;
import static android.app.PendingIntent.getActivity;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.core.app.ActivityOptionsCompat;
import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.callback.NavCallback;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.bean.room.RoomInfoResp;
import com.xscm.moduleutil.bean.room.RoomOnline;
import com.xscm.moduleutil.bean.room.RoomOnlineBean;
@@ -254,41 +260,41 @@ public class RoomManager {
// 获取房间数据
// 等待一段时间确保退出完成
try {
Thread.sleep(300);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
navigateToRoom(context, roomId, password, null, false);
// try {
// Thread.sleep(50);
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// }
// navigateToRoom(context, roomId, password, null, false);
LogUtils.dTag("RoomActivity", "fetchAndJoinRoom:"+roomId.toString());
RetrofitClient.getInstance().roomGetIn(roomId, password, new BaseObserver<RoomInfoResp>() {
// RetrofitClient.getInstance().roomGetIn(roomId, password, new BaseObserver<RoomInfoResp>() {
//
// @Override
// public void onSubscribe(Disposable d) {
// }
//
// @Override
// public void onNext(RoomInfoResp resp) {
// String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
// String token = resp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
// String roomId = resp.getRoom_info().getRoom_id(); // 房间 ID
// String rtm_token=resp.getUser_info().getAgora_rtm_token();
// SpUtil.setRtmToken(rtm_token);
// int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
// boolean enableMic = false; // 是否开启麦克风
// boolean enableJs=false; // 是否开启角色
// if (resp.getUser_info().getPit_number()!=0){
// enableJs=true;
// }
// LogUtils.e("token",token);
// LogUtils.e("roomId:",roomId);
//// 初始化 Agora 并加入房间
// AgoraManager.getInstance(context)
// .joinRoom(token, roomId, uid, enableMic,enableJs);
// cacheRoomData(roomId, resp);
// navigateToRoom(context, roomId, password, resp);
// }
// });
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(RoomInfoResp resp) {
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
String token = resp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
String roomId = resp.getRoom_info().getRoom_id(); // 房间 ID
String rtm_token = resp.getUser_info().getAgora_rtm_token();
SpUtil.setRtmToken(rtm_token);
int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
boolean enableMic = false; // 是否开启麦克风
boolean enableJs = false; // 是否开启角色
if (resp.getUser_info().getPit_number() != 0) {
enableJs = true;
}
LogUtils.e("token", token);
LogUtils.e("roomId:", roomId);
// 初始化 Agora 并加入房间
AgoraManager.getInstance(context)
.joinRoom(token, roomId, uid, enableMic, enableJs);
cacheRoomData(roomId, resp);
navigateToRoom(context, roomId, password, resp, false);
}
});
}
/**
@@ -323,18 +329,21 @@ public class RoomManager {
* @param roomInfo 房间信息
*/
private void navigateToRoom(Context context, String roomId, String password, RoomInfoResp roomInfo, boolean isOnline) {
LogUtils.dTag("RoomActivity", "navigateToRoom"+roomInfo.toString());
try {
// 构建跳转参数
Bundle bundle = new Bundle();
bundle.putString("roomId", roomId);
bundle.putBoolean("isOnline", isOnline);
bundle.putSerializable("roomInfo", roomInfo);
if (!TextUtils.isEmpty(password)) {
bundle.putString("password", password);
}
if (roomInfo != null) {
// bundle.putSerializable("roomInfo", roomInfo);
if (roomInfo == null){
LogUtils.dTag("RoomActivity", "navigateToRoom:房间信息获取存在问题");
return;
}
// 使用ARouter跳转到房间页面

View File

@@ -90,7 +90,7 @@ public class RoomMessageEvent {
private String from_pit_number;
private String to_pit_number;
private String gift_num;
private int gift_num;
private RedPacketInfo redpacketInfo;
private String redpacket_id;

View File

@@ -1,6 +1,7 @@
package com.xscm.moduleutil.dialog;
import static com.blankj.utilcode.util.ActivityUtils.startActivity;
import static com.tencent.qcloud.network.sonar.utils.Utils.isNetworkAvailable;
import android.app.Dialog;
import android.content.Context;
@@ -46,10 +47,26 @@ public class PolicyDialog extends Dialog {
ClickableSpan clickSpan = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
Intent intent = new Intent(getContext(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6");
intent.putExtra("title", "用户协议");
startActivity(intent);
// Intent intent = new Intent(getContext(), WebViewActivity.class);
// intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6");
// intent.putExtra("title", "用户协议");
// startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", "file:///android_asset/page_yongh.html").withString("title", "用户协议").navigation();
// 检查网络连接状态
if (isNetworkAvailable(getContext())) {
// 有网络时加载网络资源
Intent intent = new Intent(getContext(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6");
intent.putExtra("title", "用户协议");
startActivity(intent);
} else {
// 无网络时加载本地资源
ARouter.getInstance().build(ARouteConstants.H5)
.withString("url", "file:///android_asset/page_yongh.html")
.withString("title", "用户协议")
.navigation();
}
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6" ).withString("title", "用户协议").navigation();
}
@@ -63,11 +80,20 @@ public class PolicyDialog extends Dialog {
ClickableSpan ysClickSpan = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
Intent intent = new Intent(getContext(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4");
intent.putExtra("title", "隐私协议");
startActivity(intent);
// Intent intent = new Intent(getContext(), WebViewActivity.class);
// intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4");
// intent.putExtra("title", "隐私协议");
// startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", "file:///android_asset/page_show.html").withString("title", "隐私协议").navigation();
if (isNetworkAvailable(getContext())) {
Intent intent = new Intent(getContext(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4");
intent.putExtra("title", "隐私协议");
startActivity(intent);
}else {
ARouter.getInstance().build(ARouteConstants.H5).withString("url", "file:///android_asset/page_show.html").withString("title", "隐私协议").navigation();
}
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
}

View File

@@ -421,7 +421,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
xlhUser.setNickname(message.getText().getFromUserInfo().getNickname());
mBinding.gvXyz.setModel(xlhUser);
mBinding.qxDjs.setEndTime(endTime);
mBinding.tvNumber.setText("x"+(message.getText().getGift_num() != null ? message.getText().getGift_num() : "0"));
mBinding.tvNumber.setText("x"+(message.getText().getGift_num()));
isDrawing=false;
}
}

View File

@@ -632,11 +632,12 @@ public class RetrofitClient {
sApiServer.roomRanking(type).compose(new DefaultTransformer<>()).subscribe(observer);
} else if (ranking_type.equals("1") || ranking_type.equals("2")) {
sApiServer.wealthRanking(ranking_type, type).compose(new DefaultTransformer<>()).subscribe(observer);
} else if (ranking_type.equals("3")) {
sApiServer.guildRanking().compose(new DefaultTransformer<>()).subscribe(observer);
} else if (ranking_type.equals("4")) {
}else if (ranking_type.equals("3")) {
sApiServer.loveRanking(type).compose(new DefaultTransformer<>()).subscribe(observer);
}
else if (ranking_type.equals("4")) {
sApiServer.guildRanking().compose(new DefaultTransformer<>()).subscribe(observer);
}
}
public void dailyTasksBoxRecord(BaseObserver<List<GiftBoxRecordBean>> observer) {

View File

@@ -1,6 +1,7 @@
package com.xscm.moduleutil.utils.config;
public enum EnvironmentEnum {
// "https://vespa.qxyushen.top/",
PRODUCTION(//生产环境
"https://vespa.qxyushen.top/",
"KvNmqZc+VMzO4CfGMd5zmG6w6OFwpFO/19TwXUWfHDOBgmnl9DgIuE+kbrjNNnxqhtP3pH7bBrnSaSeFtunr72q6sgpLsfuswcUroMvz2slaTBcNzCaLi+GSnM3gB/GdO47mwLdk+iYBTvPUOCIuT608Z29z09w+vPeUDoMCHJBGXu6uh7Nj6PtV1dfGoUvByk1ZF0WYVjIqKDcb3tXY4jonFh3XAWhzMy8xKwN6F2nuK2IcdIwaSPsvuMZmhatP6f9kOE+vnfweyCHS3RxiG474WIoZGJM8omrl3/pOVqE=",

View File

@@ -118,6 +118,8 @@ public class GiftDisplayManager {
// 处理队列
processGiftQueue();
// 确保每次接收礼物后都处理队列
mainHandler.postDelayed(this::processGiftQueue, 50);
}
private GiftDisplayView findDisplayingViewForGift(GiftBean gift) {
@@ -141,11 +143,12 @@ public class GiftDisplayManager {
private void processGiftQueue() {
if (isProcessingQueue) {
Log.d("GiftDisplayManager", "Already processing queue, skip");
return;
}
isProcessingQueue = true;
Log.d("GiftDisplayManager", "Start processing queue, size: " + giftQueue.size());
// 循环处理队列直到队列为空或没有可用视图
while (!giftQueue.isEmpty()) {
GiftDisplayView availableView = findAvailableDisplayView();
@@ -195,7 +198,8 @@ public class GiftDisplayManager {
}
// 延迟一下再处理队列,确保视图状态完全重置
mainHandler.postDelayed(this::processGiftQueue, 100);
// 立即处理队列,而不是延迟
mainHandler.post(this::processGiftQueue);
}
public void clearAll() {

View File

@@ -0,0 +1,63 @@
package com.xscm.moduleutil.widget;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import androidx.appcompat.widget.AppCompatImageView;
import com.xscm.moduleutil.R;
/**
* com.xscm.moduleutil.widget
* qx
* 2025/10/24
* 自适应图片展示
*/
public class AdaptiveImageView extends AppCompatImageView {
public AdaptiveImageView(Context context) {
super(context);
}
public AdaptiveImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public AdaptiveImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
Log.d("DebugImageView", "=== onMeasure START ===");
Log.d("DebugImageView", "widthMeasureSpec: " + MeasureSpec.toString(widthMeasureSpec));
Log.d("DebugImageView", "heightMeasureSpec: " + MeasureSpec.toString(heightMeasureSpec));
// 先调用父类测量
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
Log.d("DebugImageView", "After super - Width: " + getMeasuredWidth() + ", Height: " + getMeasuredHeight());
Drawable drawable = getDrawable();
if (drawable != null) {
Log.d("DebugImageView", "Drawable - Width: " + drawable.getIntrinsicWidth() + ", Height: " + drawable.getIntrinsicHeight());
}
// 强制设置为最小尺寸,确保不会太小
int measuredWidth = getMeasuredWidth();
int measuredHeight = getMeasuredHeight();
int minSize = (int) getContext().getResources().getDimension(R.dimen.dp_40);
if (measuredWidth < minSize) {
measuredWidth = minSize;
}
if (measuredHeight < minSize) {
measuredHeight = minSize;
}
Log.d("DebugImageView", "Final - Width: " + measuredWidth + ", Height: " + measuredHeight);
Log.d("DebugImageView", "=== onMeasure END ===");
setMeasuredDimension(measuredWidth, measuredHeight);
}
}

View File

@@ -1080,11 +1080,12 @@ public class AvatarFrameView extends FrameLayout {
// 隐藏所有视图
// if (playerView != null) playerView.setVisibility(View.GONE);
if (svgaSurface != null) svgaSurface.setVisibility(View.GONE);
mBinding.playView.setVisibility(View.GONE);
// 停止播放器
if (mBinding != null && mBinding.playView != null) {
mBinding.playView.stopPlay();
mBinding.playView.setVisibility(View.GONE);
}
} catch (Exception e) {
LogUtils.e(TAG, "Error in clearPrevious: " + e.getMessage());

View File

@@ -214,8 +214,10 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
//自动调节麦位波纹
// if (!TextUtils.isEmpty(bean.getDress_picture())) {
mIvRipple.setScaleX(1.1f);
mIvRipple.setScaleY(1.1f);
if (mIvRipple != null) {
mIvRipple.setScaleX(1.1f);
mIvRipple.setScaleY(1.1f);
}
// } else {
// mIvRipple.setScaleX(0.9f);
// mIvRipple.setScaleY(0.9f);
@@ -256,6 +258,8 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
AgoraManager.getInstance(getContext()).addSoundLevelListener(new SoundLevelUpdateListener() {
@Override
public void onRemoteSoundLevelUpdate(String userId, int soundLevel) {
if (mIvRipple == null)
return;
if (userId.equals(pitBean.getUser_id())) {
if (soundLevel == 0) {
mIvRipple.post(() -> {
@@ -281,6 +285,8 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
@Override
public void onLocalSoundLevelUpdate(int volume) {
if (mIvRipple == null)
return;
if (volume == 0) {
mIvRipple.post(() -> {
mIvRipple.setVisibility(GONE);

View File

@@ -0,0 +1,297 @@
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 lxj$
* @Time 2025-8-6 17:27:29$ $
* @Description 二卡八视图控件$
*/
public class RoomSingSongWheat2View extends BaseWheatView {
public ImageView mIvTagBoss;
public TextView mTvTime;
public TextView tv_time_pk;
public boolean isClickListenerSet = false;
private boolean showBoss;//显示老板标识
public RoomSingSongWheat2View(Context context) {
this(context, null, 0);
}
public RoomSingSongWheat2View(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public RoomSingSongWheat2View(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void initPit(Context context, AttributeSet attrs) {
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);
}
@Override
protected int getLayoutId() {
return R.layout.room_view_sing_wheat_2;
}
@Override
protected void setPitData(RoomPitBean bean) {
if (bean == null) return;
sex = bean.getSex();
pitBean = bean; // 统一使用参数 bean
if (isOn()) {
handleOnState(bean);
} else {
handleOffState(bean);
}
updateSexIcon();
// updateCharmViewVisibility(bean);
updatePkState(bean);
iv_on_line.setVisibility(GONE);
}
private void handleOnState(RoomPitBean bean) {
mTvName.setText(bean.getNickname());
ImageUtils.loadHeadCC(bean.getAvatar(), mRiv);
mCharmView.setVisibility(VISIBLE);
if (mIvFrame != null) {
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);
}
if (mIvFrame != null) {
mIvFrame.stopAll();
mIvFrame.setVisibility(INVISIBLE);
}
mIvFace.remove();
}
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();
}
}
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(bean.getCharm(), false);
mCharmView.setVisibility(GONE);
} else {
tv_time_pk.setVisibility(GONE);
}
} else {
tv_time_pk.setVisibility(GONE);
if (isOn()) {
mCharmView.setVisibility(VISIBLE);
} else {
mCharmView.setVisibility(GONE);
}
}
}
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));
} else {
tv_time_pk.setText(value);
}
} catch (Exception e) {
e.printStackTrace();
tv_time_pk.setText("0"); // 设置默认值防止UI异常
}
}
}
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);
}
// 添加内存释放方法
public void releaseResources() {
// 清理头像加载
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);
}
}
@Override
protected void onDetachedFromWindow() {
// 视图从窗口分离时释放资源
releaseResources();
super.onDetachedFromWindow();
}
@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) {
// 暂无实现
}
@Override
public void unRegister(Object obj) {
}
}

View File

@@ -1,5 +1,6 @@
package com.xscm.moduleutil.widget;
import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.View;
@@ -17,6 +18,8 @@ import com.xscm.moduleutil.utils.SpUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* @Author lxj$
@@ -50,97 +53,30 @@ public class WheatLayoutSingManager {
this.container = container;
}
public void setWheatData(List<RoomPitBean> pitList) {
public void setWheatData(List<RoomPitBean> pitList, boolean isFirst) {
// 检查容器状态
if (container == null || !isContainerValid()) {
if (container == null) {
return;
}
this.pitList = pitList;
restoreMultiWheat();
}
public void setWheatDataPk(List<RoomPitBean> pitList, int layoutType) {
// 检查容器状态
if (container == null || !isContainerValid()) {
return;
}
this.pitList = pitList;
restoreMultiWheatPk(layoutType);
restoreMultiWheat(isFirst);
}
public void setOnWheatClickListener(@Nullable OnWheatClickListener listener) {
this.wheatClickListener = listener;
}
public void showSingleWheat(int pitNumber) {
public void restoreMultiWheat(boolean isFirst) {
// 检查容器状态
if (container == null || !isContainerValid()) {
return;
}
if (isSingleMode && this.currentSinglePit == pitNumber) return;
try {
container.removeAllViews();
} catch (Exception e) {
// 忽略异常,继续执行
return;
}
if (pitNumber < 1 || pitNumber > 10 || pitList == null || pitList.size() < 10)
return;
RoomPitBean bean = pitList.get(pitNumber - 1);
singleWheatView = new RoomSingSongWheatView(context);
singleWheatView.pitNumber = String.valueOf(pitNumber);
singleWheatView.setData(bean);
// 默认设置为 MATCH_PARENT也可以自定义
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
params.setMargins(20, 20, 20, 20);
singleWheatView.setLayoutParams(params);
GifAvatarOvalView avatarView = (GifAvatarOvalView) singleWheatView.mRiv;
avatarView.setOnClickListener(v -> {
if (wheatClickListener != null) {
wheatClickListener.onWheatClick(singleWheatView, pitNumber);
}
restoreMultiWheat();
});
WheatCharmView charmView = singleWheatView.mCharmView;
charmView.setOnClickListener(v -> {
if (wheatClickListener != null) {
wheatClickListener.onMeilingClick(singleWheatView, Integer.parseInt(singleWheatView.pitNumber));
}
});
// // 添加点击事件
singleWheatView.setOnClickListener(v -> {
if (wheatClickListener != null) {
wheatClickListener.onMakeWheatClick(singleWheatView, pitNumber);
}
restoreMultiWheat();
});
container.addView(singleWheatView);
isSingleMode = true;
currentSinglePit = pitNumber;
}
public void restoreMultiWheat() {
// 检查容器状态
if (container == null || !isContainerValid()) {
if (container == null) {
return;
}
try {
container.removeAllViews();
if (multiWheatViews != null && multiWheatViews.size() != 10) {
container.removeAllViews();
}
} catch (Exception e) {
// 忽略异常,继续执行
return;
@@ -150,86 +86,131 @@ public class WheatLayoutSingManager {
return;
}
multiWheatViews.clear();
// multiWheatViews.clear();
int screenWidth = getScreenWidth();
int itemWidth = screenWidth / 4; // 每个控件宽度为屏幕宽度的 1/4
LinearLayout row = new LinearLayout(context);
row.setOrientation(LinearLayout.HORIZONTAL);
if (multiWheatViews.size() == 10){
for (int i = 0; i < multiWheatViews.size(); i++){
multiWheatViews.get(i).setData(pitList.get(pitIndexMap[i] - 1));
}
}else {
for (int i = 0; i < 10; i++) {
int pitNumber = pitIndexMap[i];
if (isFirst){
RoomSingSongWheat2View wheatView = new RoomSingSongWheat2View( context);
wheatView.pitNumber = String.valueOf(pitNumber);
wheatView.setData(pitList.get(pitNumber - 1));
for (int i = 0; i < 10; i++) {
int pitNumber = pitIndexMap[i];
RoomSingSongWheatView wheatView = new RoomSingSongWheatView(context);
wheatView.pitNumber = String.valueOf(pitNumber);
wheatView.setData(pitList.get(pitNumber - 1));
multiWheatViews.add(wheatView);
LinearLayout.LayoutParams params;
LinearLayout.LayoutParams params;
if (i == 0) {
int fixedHeightInDp = 110; // 固定高度为 100dp
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
// 第一个控件:左边距 86dp右边距 100dp
params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
params.rightMargin = dpToPx(50);
} else if (i == 1) {
int fixedHeightInDp = 110; // 固定高度为 100dp
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
// 第二个控件:右边距 86dp
params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
} else {
int fixedHeightInDp = 90; // 固定高度为 100dp
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
params = new LinearLayout.LayoutParams(itemWidth - 30, fixedHeightInPx + 30);
// 其他控件保持原有逻辑
if (i == 0) {
int fixedHeightInDp = 110; // 固定高度为 100dp
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
// 第一个控件:左边距 86dp右边距 100dp
params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
params.rightMargin = dpToPx(50);
} else if (i == 1) {
int fixedHeightInDp = 110; // 固定高度为 100dp
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
// 第二个控件:右边距 86dp
params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
} else {
int fixedHeightInDp = 90; // 固定高度为 100dp
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
params = new LinearLayout.LayoutParams(itemWidth - 30, fixedHeightInPx + 30);
// 其他控件保持原有逻辑
params.setMargins(0, 0, 0, 0); // 不设右边距,由 row padding 控制
}
wheatView.setLayoutParams(params);
row.addView(wheatView);
// 第一行添加两个后换行
if (i == 1) {
container.addView(row);
row = new LinearLayout(context);
row.setOrientation(LinearLayout.HORIZONTAL);
} else if (i > 1 && (i - 2) % 4 == 3) {
container.addView(row);
row = new LinearLayout(context);
row.setOrientation(LinearLayout.HORIZONTAL);
}
}else {
RoomSingSongWheatView wheatView = new RoomSingSongWheatView(context);
wheatView.pitNumber = String.valueOf(pitNumber);
wheatView.setData(pitList.get(pitNumber - 1));
multiWheatViews.add(wheatView);
LinearLayout.LayoutParams params;
if (i == 0) {
int fixedHeightInDp = 110; // 固定高度为 100dp
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
// 第一个控件:左边距 86dp右边距 100dp
params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
params.rightMargin = dpToPx(50);
} else if (i == 1) {
int fixedHeightInDp = 110; // 固定高度为 100dp
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
// 第二个控件:右边距 86dp
params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
} else {
int fixedHeightInDp = 90; // 固定高度为 100dp
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
params = new LinearLayout.LayoutParams(itemWidth - 30, fixedHeightInPx + 30);
// 其他控件保持原有逻辑
params.setMargins(0, 0, 0, 0); // 不设右边距,由 row padding 控制
}
wheatView.setLayoutParams(params);
GifAvatarOvalView avatarView = (GifAvatarOvalView) wheatView.mRiv;
avatarView.setOnClickListener(v -> {
if (wheatClickListener != null) {
wheatClickListener.onWheatClick(wheatView, pitNumber);
}
});
WheatCharmView charmView = wheatView.mCharmView;
charmView.setOnClickListener(v -> {
if (wheatClickListener != null) {
ToastUtils.show("点击了麦位");
wheatClickListener.onMeilingClick(wheatView, pitNumber);
}
});
wheatView.setOnClickListener(v -> {
if (wheatClickListener != null) {
wheatClickListener.onMeilingClick(wheatView, Integer.parseInt(wheatView.pitNumber));
}
});
row.addView(wheatView);
// 第一行添加两个后换行
if (i == 1) {
container.addView(row);
row = new LinearLayout(context);
row.setOrientation(LinearLayout.HORIZONTAL);
} else if (i > 1 && (i - 2) % 4 == 3) {
container.addView(row);
row = new LinearLayout(context);
row.setOrientation(LinearLayout.HORIZONTAL);
}
}
params.setMargins(0, 0, 0, 0); // 不设右边距,由 row padding 控制
}
wheatView.setLayoutParams(params);
GifAvatarOvalView avatarView = (GifAvatarOvalView) wheatView.mRiv;
avatarView.setOnClickListener(v -> {
if (wheatClickListener != null) {
wheatClickListener.onWheatClick(wheatView, pitNumber);
}
});
WheatCharmView charmView = wheatView.mCharmView;
charmView.setOnClickListener(v -> {
if (wheatClickListener != null) {
ToastUtils.show("点击了麦位");
wheatClickListener.onMeilingClick(wheatView, pitNumber);
}
});
wheatView.setOnClickListener(v -> {
if (wheatClickListener != null) {
wheatClickListener.onMeilingClick(wheatView, Integer.parseInt(wheatView.pitNumber));
}
});
row.addView(wheatView);
// 第一行添加两个后换行
if (i == 1) {
// 添加最后一行可能存在的剩余 view
if (row.getChildCount() > 0) {
container.addView(row);
row = new LinearLayout(context);
row.setOrientation(LinearLayout.HORIZONTAL);
} else if (i > 1 && (i - 2) % 4 == 3) {
container.addView(row);
row = new LinearLayout(context);
row.setOrientation(LinearLayout.HORIZONTAL);
}
isSingleMode = false;
currentSinglePit = -1;
}
// 添加最后一行可能存在的剩余 view
if (row.getChildCount() > 0) {
container.addView(row);
}
isSingleMode = false;
currentSinglePit = -1;
}
public void restoreMultiWheatPk(int layoutType) {