1:修改BUG
This commit is contained in:
@@ -4,25 +4,25 @@ import static androidx.core.content.ContextCompat.getSystemService;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
@@ -44,15 +44,14 @@ import com.hjq.toast.ToastUtils;
|
||||
import com.tencent.qcloud.tuikit.tuichat.bean.ChatInfo;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.bean.XLHBean;
|
||||
import com.xscm.moduleutil.event.MqttBean;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.BackgroundManager;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.DialogUtils;
|
||||
import com.xscm.moduleutil.utils.DisplayUtil;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.LanguageUtil;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
@@ -67,10 +66,6 @@ import java.util.Map;
|
||||
public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends AppCompatActivity
|
||||
implements BackgroundManager.BackgroundUpdateListener, ColorManager.ColorChangeListener {
|
||||
|
||||
// @Override
|
||||
// protected void attachBaseContext(Context newBase) {
|
||||
// super.attachBaseContext(LanguageUtil.attachBaseContext(newBase));
|
||||
// }
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
// 设置字体缩放比例为1.0f,即不跟随系统字体大小变化
|
||||
@@ -398,11 +393,6 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
return false;
|
||||
}
|
||||
|
||||
// 在类中添加以下成员变量
|
||||
private final List<MqttBean> messageQueue = new ArrayList<>(); // 消息队列
|
||||
private boolean isPlaying = false; // 播放状态标志
|
||||
private boolean isPlaying2 = false; // 播放状态标志
|
||||
private final Object queueLock = new Object(); // 队列同步锁
|
||||
|
||||
/// 礼物特效
|
||||
// 在类中添加以下成员变量
|
||||
@@ -420,14 +410,17 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
public void onMessageReceived(MqttBean mqttBean) {
|
||||
LogUtils.e("收到MQTT", mqttBean);
|
||||
if (mqttBean == null) return;
|
||||
if (SpUtil.getFloatingScreen() == 1) {
|
||||
synchronized (mqttQueueLock) {
|
||||
|
||||
synchronized (mqttQueueLock) {
|
||||
|
||||
mqttMessageQueue.addAll(mqttBean.getList());
|
||||
if (!isMqttPlaying) {
|
||||
isMqttPlaying = true;
|
||||
processNextMqttMessage();
|
||||
mqttMessageQueue.addAll(mqttBean.getList());
|
||||
if (!isMqttPlaying) {
|
||||
isMqttPlaying = true;
|
||||
processNextMqttMessage();
|
||||
}
|
||||
}
|
||||
}else {
|
||||
mqttMessageQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,13 +429,16 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
public void onEvent(XLHBean event) {
|
||||
LogUtils.e("收到XLH", event);
|
||||
if (event == null) return;
|
||||
|
||||
synchronized (xlhQueueLock) {
|
||||
xlhMessageQueue.add(event);
|
||||
if (!isXlhPlaying) {
|
||||
isXlhPlaying = true;
|
||||
processNextXlhMessage();
|
||||
if (SpUtil.getFloatingScreen() == 1) {
|
||||
synchronized (xlhQueueLock) {
|
||||
xlhMessageQueue.add(event);
|
||||
if (!isXlhPlaying) {
|
||||
isXlhPlaying = true;
|
||||
processNextXlhMessage();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
xlhMessageQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,11 +562,15 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resetAndStartMqttAnimation(View view, Runnable onAnimationEnd) {
|
||||
try {
|
||||
view.setTranslationX(view.getWidth());
|
||||
int screenWidth = getScreenWidth();
|
||||
// 设置初始位置:在屏幕右侧外部(完全不可见)
|
||||
view.setTranslationX(screenWidth);
|
||||
|
||||
|
||||
ObjectAnimator animator1 = ObjectAnimator.ofFloat(view, "translationX", view.getWidth(), 0f);
|
||||
// ObjectAnimator animator1 = ObjectAnimator.ofFloat(view, "translationX", getScreenWidth(), (getScreenWidth() - view.getMeasuredWidth()) / 2f);
|
||||
animator1.setDuration(1500);
|
||||
animator1.setInterpolator(new DecelerateInterpolator(2.0f));
|
||||
animator1.start();
|
||||
@@ -578,6 +578,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
view.postDelayed(() -> {
|
||||
try {
|
||||
ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "translationX", 0f, -view.getWidth());
|
||||
// ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "translationX", (getScreenWidth() - view.getMeasuredWidth()) / 2f, -view.getMeasuredWidth());
|
||||
animator2.setDuration(1500);
|
||||
animator2.setInterpolator(new DecelerateInterpolator(2.0f));
|
||||
animator2.addListener(new AnimatorListenerAdapter() {
|
||||
@@ -602,7 +603,15 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
}
|
||||
|
||||
// 添加获取屏幕宽度的方法
|
||||
private int getScreenWidth() {
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
if (getWindowManager() != null) {
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
return displayMetrics.widthPixels;
|
||||
}
|
||||
return getResources().getDisplayMetrics().widthPixels;
|
||||
}
|
||||
private void resetAndStartXlhAnimation(View view, Runnable onAnimationEnd) {
|
||||
try {
|
||||
view.setTranslationX(view.getWidth());
|
||||
@@ -680,8 +689,9 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
private void handleItemClick(XLHBean xlhBean) {
|
||||
// 这里可以根据实际需求实现跳转逻辑
|
||||
// 例如:跳转到礼物详情页面、用户主页等
|
||||
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", xlhBean.getRoom_id()).navigation();
|
||||
// 使用缓存数据进入房间
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), xlhBean.getRoom_id(), "");
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", xlhBean.getRoom_id()).navigation();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user