合并 fix bugs

This commit is contained in:
2025-11-22 11:22:41 +08:00
17 changed files with 153 additions and 90 deletions

View File

@@ -23,7 +23,7 @@ public class UserInfo extends BaseEvent implements Serializable {
public static final String FEMALE = "2";
public static final String MALE = "1";
private int id;
private int user_id; //用户id
private int user_id = 0; //用户id
private String user_code;//用户id码
private String avatar;//头像
private String nickname;//昵称

View File

@@ -28,13 +28,21 @@ public class RoomPitBean implements Serializable {
* dress_picture :
*/
public RoomPitBean(){
}
public RoomPitBean(String pit_number){
this.pit_number = pit_number;
}
private String id;//id
private String pit_number="";//麦位号
private String state;//麦位状态 正常 1封麦3禁麦
private int is_lock;//0未锁麦 1锁麦
private int is_mute;//0未禁麦 1禁麦
private int count_down;//麦位倒计时
private String user_id="";//麦位上用户id
private String user_id="0";//麦位上用户id
private String nickname;//麦位上用户昵称
private String avatar;//用户头像
private String sex;//性别

View File

@@ -65,7 +65,12 @@ public final class DataLogger implements DataLoggingInterceptor.Logger {
if (message.startsWith(DataLoggingInterceptor.sLogEndFlag)) {
if (mMessage.toString().contains("Xintiao/keep_xintiao"))
return;
LogUtils.d(mMessage.toString());
try {
LogUtils.d(mMessage.toString());
} catch (StringIndexOutOfBoundsException e) {
// 处理异常,记录日志或使用默认值
LogUtils.e("打印 JSON 数据时出错:" + e.getMessage());
}
return;
}
@@ -75,8 +80,11 @@ public final class DataLogger implements DataLoggingInterceptor.Logger {
message = formatJson(decodeUnicode(message));
}
// 追加消息
try { mMessage.append(message.concat("\n"));
} catch (Exception ignored) {}
try {
mMessage.append(message.concat("\n"));
} catch (Exception ignored) {
LogUtils.e("打印 JSON append时出错" + ignored.getMessage());
}
}
@Override

View File

@@ -5,6 +5,8 @@ import android.os.Looper;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.blankj.utilcode.util.LogUtils;
import com.xscm.moduleutil.bean.GiftBean;
import com.xscm.moduleutil.bean.RoonGiftModel;
@@ -66,14 +68,14 @@ public class GiftDisplayManager {
final int finalI = i;
displayView.setGiftAnimationListener(view -> {
Log.d("GiftDisplayManager", "Gift animation ended on view: " + finalI);
LogUtils.e("GiftDisplayManager", "Gift animation ended on view: " + finalI);
onGiftAnimationEnd(view);
});
container.addView(displayView);
displayViews.add(displayView);
Log.d("GiftDisplayManager", "Created display view " + i);
LogUtils.e("GiftDisplayManager", "Created display view " + i +"____"+displayViews.size());
}
}
@@ -83,7 +85,7 @@ public class GiftDisplayManager {
}
if (gift == null) return;
Log.d("GiftDisplayManager", "Received gift: " + gift.getSenderName() +
LogUtils.e("GiftDisplayManager", "Received gift: " + gift.getSenderName() +
" - " + gift.getGift_name() + " x" + gift.getNumber());
mainHandler.post(() -> internalReceiveGift(gift));
@@ -99,8 +101,8 @@ public class GiftDisplayManager {
GiftBean accumulatedGift = accumulatedGifts.get(key);
if (accumulatedGift != null) {
accumulatedGift.setNumber(accumulatedGift.getNumber() + gift.getNumber());
displayingView.updateGiftCount(accumulatedGift.getNumber());
Log.d("GiftDisplayManager", "Gift accumulated: " + gift.getGift_name() +
displayingView.updateGiftCount(accumulatedGift);
LogUtils.e("GiftDisplayManager", "Gift accumulated: " + gift +
" x" + accumulatedGift.getNumber());
}
} else {
@@ -111,11 +113,11 @@ public class GiftDisplayManager {
String key = gift.getGiftKey();
accumulatedGifts.put(key, gift.clone());
availableView.showGift(gift);
Log.d("GiftDisplayManager", "Immediately display gift on view: " + availableView.getTag());
LogUtils.e("GiftDisplayManager", "Immediately display gift on view: " + gift);
} else {
// 没有可用视图,加入队列
giftQueue.offer(gift);
Log.d("GiftDisplayManager", "Added to queue, current queue size: " + giftQueue.size());
LogUtils.e("GiftDisplayManager", gift+" Added to queue, current queue size: " + giftQueue.size());
}
}
@@ -146,12 +148,12 @@ public class GiftDisplayManager {
private void processGiftQueue() {
if (isProcessingQueue) {
Log.d("GiftDisplayManager", "Already processing queue, skip");
LogUtils.e("GiftDisplayManager", "Already processing queue, skip");
return;
}
isProcessingQueue = true;
Log.d("GiftDisplayManager", "Start processing queue, size: " + giftQueue.size());
LogUtils.e("GiftDisplayManager", "Start processing queue, size: " + giftQueue.size());
// 循环处理队列直到队列为空或没有可用视图
while (!giftQueue.isEmpty()) {
GiftDisplayView availableView = findAvailableDisplayView();
@@ -168,16 +170,16 @@ public class GiftDisplayManager {
String key = gift.getGiftKey();
accumulatedGifts.put(key, gift.clone());
availableView.showGift(gift);
Log.d("GiftDisplayManager", "Display gift from queue: " + gift.getGift_name());
LogUtils.e("GiftDisplayManager", "Display gift from queue: " + gift);
} else {
// 如果已经在显示,累加到现有视图
String key = gift.getGiftKey();
GiftBean accumulatedGift = accumulatedGifts.get(key);
if (accumulatedGift != null) {
accumulatedGift.setNumber(accumulatedGift.getNumber() + gift.getNumber());
displayingView.updateGiftCount(accumulatedGift.getNumber());
Log.d("GiftDisplayManager", "Queue gift accumulated to existing: " +
gift.getNickname() + " x" + accumulatedGift.getNumber());
displayingView.updateGiftCount(accumulatedGift);
LogUtils.e("GiftDisplayManager", "Queue gift accumulated to existing: " +
gift + " x" + accumulatedGift.getNumber());
}
}
}
@@ -186,18 +188,18 @@ public class GiftDisplayManager {
// 打印队列状态
if (!giftQueue.isEmpty()) {
Log.d("GiftDisplayManager", "Still " + giftQueue.size() + " gifts waiting in queue");
LogUtils.e("GiftDisplayManager", "Still " + giftQueue.size() + " gifts waiting in queue");
}
}
private void onGiftAnimationEnd(GiftDisplayView view) {
Log.d("GiftDisplayManager", "Gift animation end on view: " + view.getTag());
LogUtils.e("GiftDisplayManager", "Gift animation end on view: " + view.getTag());
// 从累加记录中移除
if (view.getCurrentGift() != null) {
String key = view.getCurrentGift().getGiftKey();
accumulatedGifts.remove(key);
Log.d("GiftDisplayManager", "Removed accumulated record: " + key);
LogUtils.e("GiftDisplayManager", "Removed accumulated record: " + key);
}
// 延迟一下再处理队列,确保视图状态完全重置
@@ -220,7 +222,7 @@ public class GiftDisplayManager {
}
public void clearAll() {
Log.d("GiftDisplayManager", "Clear all gifts and queue");
LogUtils.e("GiftDisplayManager", "Clear all gifts and queue");
for (GiftDisplayView view : displayViews) {
view.finishAnimationImmediately();
@@ -234,16 +236,16 @@ public class GiftDisplayManager {
// 调试方法
public void printDebugInfo() {
Log.d("GiftDisplayManager", "=== Gift Display Manager Status ===");
Log.d("GiftDisplayManager", "Queue size: " + giftQueue.size());
Log.d("GiftDisplayManager", "Accumulated records: " + accumulatedGifts.size());
LogUtils.e("GiftDisplayManager", "=== Gift Display Manager Status ===");
LogUtils.e("GiftDisplayManager", "Queue size: " + giftQueue.size());
LogUtils.e("GiftDisplayManager", "Accumulated records: " + accumulatedGifts.size());
for (int i = 0; i < displayViews.size(); i++) {
GiftDisplayView view = displayViews.get(i);
Log.d("GiftDisplayManager", "View " + i + ": Animating=" + view.isAnimating() +
LogUtils.e("GiftDisplayManager", "View " + i + ": Animating=" + view.isAnimating() +
", Gift=" + (view.getCurrentGift() != null ? view.getCurrentGift().getGift_name() : "None"));
}
Log.d("GiftDisplayManager", "===================================");
LogUtils.e("GiftDisplayManager", "===================================");
}
private int dpToPx(int dp) {

View File

@@ -13,6 +13,8 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.blankj.utilcode.util.LogUtils;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.bean.GiftBean;
import com.xscm.moduleutil.utils.ImageUtils;
@@ -63,14 +65,14 @@ public class GiftDisplayView extends FrameLayout {
public void showGift(GiftBean gift) {
if (isAnimating) {
Log.w("GiftDisplayView", "View is animating, cannot show new gift");
LogUtils.e("GiftDisplayView", "View is animating, cannot show new gift");
return;
}
this.currentGift = gift;
this.isAnimating = true;
Log.d("GiftDisplayView", "Start showing gift: " + gift.getGift_name());
LogUtils.e("GiftDisplayView", "Start showing gift: " + gift.getGift_name());
// 更新UI
updateUIWithGift(gift);
@@ -87,7 +89,7 @@ public class GiftDisplayView extends FrameLayout {
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
Log.d("GiftDisplayView", "Enter animation completed: " + gift.getGift_name());
LogUtils.e("GiftDisplayView", "Enter animation completed: " + gift.getGift_name());
startHideTimer();
}
})
@@ -113,7 +115,7 @@ public class GiftDisplayView extends FrameLayout {
// 加载礼物图片
loadGiftImage(gift.getBase_image());
Log.d("GiftDisplayView", "Update UI: " + gift.getSenderName() + " - " +
LogUtils.e("GiftDisplayView", "Update UI: " + gift.getSenderName() + " - " +
gift.getGift_name() + " x" + gift.getNumber());
}
@@ -150,16 +152,25 @@ public class GiftDisplayView extends FrameLayout {
return Color.argb(255, random.nextInt(256), random.nextInt(256), random.nextInt(256));
}
public void updateGiftCount(int count) {
public void updateGiftCount(GiftBean gift) {
if (!isAnimating) {
Log.w("GiftDisplayView", "View is not animating, cannot update count");
LogUtils.e("GiftDisplayView", "View is not animating, cannot update count");
return;
}
Log.d("GiftDisplayView", "Update gift count: " + count);
LogUtils.e("GiftDisplayView", "Update gift count: " + gift);
// 更新数量显示
countTextView.setText("x" + count);
countTextView.setText("x" + gift.getNumber());
if (senderTextView.getText().toString().isEmpty()){
senderTextView.setText(gift.getNickname()!=null ? gift.getNickname() : "未知用户");
}
if (giftTextView.getText().toString().isEmpty()){
giftTextView.setText("送给 "+(gift.getSenderName() != null ? gift.getSenderName() : "未知用户") + (gift.getGift_name() != null ? gift.getGift_name() : "礼物"));
}
// 数量更新动画
countTextView.animate()
@@ -201,7 +212,7 @@ public class GiftDisplayView extends FrameLayout {
return;
}
Log.d("GiftDisplayView", "Start hide animation: " + currentGift.getGift_name());
LogUtils.e("GiftDisplayView", "Start hide animation: " + currentGift.getGift_name());
// 从右往左消失动画
animate()
@@ -211,7 +222,7 @@ public class GiftDisplayView extends FrameLayout {
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
Log.d("GiftDisplayView", "Hide animation completed: " + currentGift.getGift_name());
LogUtils.e("GiftDisplayView", "Hide animation completed: " + currentGift.getGift_name());
isAnimating = false;
if (listener != null) {
@@ -225,7 +236,7 @@ public class GiftDisplayView extends FrameLayout {
}
public void finishAnimationImmediately() {
Log.d("GiftDisplayView", "Finish animation immediately");
LogUtils.e("GiftDisplayView", "Finish animation immediately");
// 移除计时任务
if (hideRunnable != null) {

View File

@@ -2,6 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingVertical="@dimen/dp_5"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.xscm.moduleutil.widget.GifAvatarOvalView

View File

@@ -18,6 +18,7 @@
android:id="@+id/riv"
android:layout_width="0dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:layout_marginTop="@dimen/dp_12"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toStartOf="parent"
@@ -35,6 +36,7 @@
android:layout_marginEnd="-4dp"
android:layout_marginTop="-4dp"
android:layout_marginBottom="-4dp"
android:adjustViewBounds="true"
app:layout_constraintStart_toStartOf="@id/riv"
app:layout_constraintEnd_toEndOf="@id/riv"
app:layout_constraintTop_toTopOf="@id/riv"
@@ -45,9 +47,9 @@
android:id="@+id/iv_ripple"
android:layout_width="0dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
app:autoPlay="false"
app:layout_constraintHeight_percent="0.95"
app:layout_constraintWidth_percent="1"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintBottom_toBottomOf="@id/iv_frame"
app:layout_constraintEnd_toEndOf="@id/iv_frame"
app:layout_constraintStart_toStartOf="@id/iv_frame"