修改点唱页面逻辑
修改背包展示问题
This commit is contained in:
@@ -364,7 +364,8 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
private final List<MqttBean> messageQueue = new ArrayList<>(); // 消息队列
|
||||
private boolean isPlaying = false; // 播放状态标志
|
||||
private final Object queueLock = new Object(); // 队列同步锁
|
||||
///礼物特效
|
||||
|
||||
/// 礼物特效
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageReceived(MqttBean mqttBean) {
|
||||
if (mqttBean == null) {
|
||||
@@ -401,36 +402,29 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
showFloatingMessage(mqttBean);
|
||||
}
|
||||
|
||||
private View floatingView; // 成员变量保存浮动视图
|
||||
private boolean isFloatingViewAdded = false; // 标记浮动视图是否已添加到 decorView
|
||||
|
||||
private void showFloatingMessage(MqttBean mqttBean) {
|
||||
ViewGroup decorView = (ViewGroup) this.getWindow().getDecorView();
|
||||
// 如果浮动视图未创建,则创建一次
|
||||
if (floatingView == null) {
|
||||
floatingView = LayoutInflater.from(this).inflate(R.layout.item_piaoping, null);
|
||||
View floatingView = LayoutInflater.from(this).inflate(R.layout.item_piaoping, null);
|
||||
|
||||
// 设置布局参数
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
layoutParams.topMargin = com.sunfusheng.marqueeview.DisplayUtil.dip2px(this, 70);
|
||||
layoutParams.gravity = android.view.Gravity.TOP | android.view.Gravity.CENTER_HORIZONTAL;
|
||||
floatingView.setLayoutParams(layoutParams);
|
||||
// 设置布局参数
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
layoutParams.topMargin = com.sunfusheng.marqueeview.DisplayUtil.dip2px(this, 70);
|
||||
layoutParams.gravity = android.view.Gravity.TOP | android.view.Gravity.CENTER_HORIZONTAL;
|
||||
floatingView.setLayoutParams(layoutParams);
|
||||
|
||||
// 初始化动画监听器
|
||||
setupAnimationListener(floatingView, decorView);
|
||||
}
|
||||
// 初始化动画监听器
|
||||
setupAnimationListener(floatingView, decorView);
|
||||
|
||||
// 更新视图数据
|
||||
updateFloatingViewData(mqttBean);
|
||||
updateFloatingViewData(floatingView, mqttBean);
|
||||
|
||||
// 如果浮动视图未添加到 decorView,则添加
|
||||
if (!isFloatingViewAdded) {
|
||||
decorView.addView(floatingView);
|
||||
isFloatingViewAdded = true;
|
||||
}
|
||||
decorView.addView(floatingView);
|
||||
|
||||
// 重置视图位置并开始动画
|
||||
resetAndStartAnimation(floatingView);
|
||||
@@ -464,10 +458,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
// 动画结束后移除悬浮窗
|
||||
if (isFloatingViewAdded) {
|
||||
decorView.removeView(floatingView);
|
||||
isFloatingViewAdded = false;
|
||||
}
|
||||
decorView.removeView(floatingView);
|
||||
|
||||
// 标记播放结束并处理下一个消息
|
||||
synchronized (queueLock) {
|
||||
@@ -503,7 +494,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
private void updateFloatingViewData(MqttBean mqttBean) {
|
||||
private void updateFloatingViewData(View floatingView, MqttBean mqttBean) {
|
||||
TextView textView = floatingView.findViewById(R.id.tv_name);
|
||||
TextView textView2 = floatingView.findViewById(R.id.tv_to_name);
|
||||
TextView tv_time = floatingView.findViewById(R.id.tv_num);
|
||||
@@ -627,8 +618,6 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
|
||||
|
||||
// 在类中添加新的成员变量
|
||||
private View xlhFloatingView; // XLH类型的浮动视图
|
||||
private boolean isXlhFloatingViewAdded = false; // 标记XLH浮动视图是否已添加到 decorView
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(XLHBean event) {
|
||||
@@ -640,32 +629,28 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
ViewGroup decorView = (ViewGroup) this.getWindow().getDecorView();
|
||||
|
||||
// 如果XLH浮动视图未创建,则创建一次
|
||||
if (xlhFloatingView == null) {
|
||||
xlhFloatingView = LayoutInflater.from(this).inflate(R.layout.item_piaoping_xlh, null);
|
||||
View xlhFloatingView = LayoutInflater.from(this).inflate(R.layout.item_piaoping_xlh, null);
|
||||
|
||||
// 设置布局参数
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
layoutParams.topMargin = com.sunfusheng.marqueeview.DisplayUtil.dip2px(this, 100);
|
||||
layoutParams.gravity = android.view.Gravity.TOP | android.view.Gravity.CENTER_HORIZONTAL;
|
||||
xlhFloatingView.setLayoutParams(layoutParams);
|
||||
// 设置布局参数
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
layoutParams.topMargin = com.sunfusheng.marqueeview.DisplayUtil.dip2px(this, 100);
|
||||
layoutParams.gravity = android.view.Gravity.TOP | android.view.Gravity.CENTER_HORIZONTAL;
|
||||
xlhFloatingView.setLayoutParams(layoutParams);
|
||||
|
||||
// 初始化动画监听器
|
||||
setupXlhAnimationListener(xlhFloatingView, decorView);
|
||||
} // 更新视图数据
|
||||
updateXlhFloatingViewData(event);
|
||||
// 初始化动画监听器
|
||||
setupXlhAnimationListener(xlhFloatingView, decorView);
|
||||
updateXlhFloatingViewData(xlhFloatingView, event);
|
||||
|
||||
// 如果浮动视图未添加到 decorView,则添加
|
||||
if (!isXlhFloatingViewAdded) {
|
||||
decorView.addView(xlhFloatingView);
|
||||
isXlhFloatingViewAdded = true;
|
||||
}
|
||||
decorView.addView(xlhFloatingView);
|
||||
|
||||
// 重置视图位置并开始动画
|
||||
resetAndStartXlhAnimation(xlhFloatingView);
|
||||
}
|
||||
|
||||
private void setupXlhAnimationListener(View floatingView, ViewGroup decorView) {
|
||||
// 为视图添加一个全局布局监听器,确保在视图完全加载后再设置动画
|
||||
floatingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@@ -694,10 +679,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
// 动画结束后移除悬浮窗
|
||||
if (isXlhFloatingViewAdded) {
|
||||
decorView.removeView(floatingView);
|
||||
isXlhFloatingViewAdded = false;
|
||||
}
|
||||
decorView.removeView(floatingView);
|
||||
|
||||
// 标记播放结束并处理下一个消息
|
||||
synchronized (queueLock) {
|
||||
@@ -733,11 +715,11 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
private void updateXlhFloatingViewData(XLHBean xlhBean) {
|
||||
private void updateXlhFloatingViewData(View xlhFloatingView, XLHBean xlhBean) {
|
||||
TextView textView = xlhFloatingView.findViewById(R.id.tv_name);
|
||||
ImageView xlh_image = xlhFloatingView.findViewById(R.id.im_xlh);
|
||||
|
||||
if (xlhBean!=null){
|
||||
if (xlhBean != null) {
|
||||
xlh_image.setImageDrawable(xlhBean.getFrom_type() == 1 ? getResources().getDrawable(R.mipmap.xlh_jjks) : getResources().getDrawable(R.mipmap.xlh_zsks));
|
||||
|
||||
textView.setText(xlhBean.getText());
|
||||
|
||||
@@ -4,9 +4,10 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MyBagDataBean {
|
||||
private String title;
|
||||
private String giftName;
|
||||
private String time;
|
||||
private String base_image;
|
||||
private String remarks; //收入说明
|
||||
private String gift_num;//礼物数量
|
||||
private String gift_name;//礼物名称
|
||||
private String gift_image;//礼物图片
|
||||
private String time;//时间
|
||||
|
||||
}
|
||||
|
||||
@@ -883,6 +883,7 @@ public class AgoraManager {
|
||||
} else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED) {
|
||||
LogUtils.e("lxj", "daki");
|
||||
musicPlayer.open(mSongCode, 0);
|
||||
|
||||
isPreload(mSongCode, type);
|
||||
} else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_OPENING) {
|
||||
LogUtils.e("lxj", musicPlayer.getState());
|
||||
|
||||
@@ -14,19 +14,7 @@
|
||||
android:clipToPadding="false">
|
||||
|
||||
<!--说话动态图 (麦圈) - 与头像大小相同-->
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/iv_ripple"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:autoPlay="false"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintHeight_default="percent"
|
||||
app:layout_constraintHeight_percent="0.5"
|
||||
app:loopCount="0"
|
||||
app:source="ripple3695.svga" />
|
||||
|
||||
<!-- <com.xscm.moduleutil.widget.AvatarFrameView-->
|
||||
<!-- android:id="@+id/iv_ripple"-->
|
||||
<!-- android:layout_width="0dp"-->
|
||||
@@ -55,6 +43,20 @@
|
||||
app:layout_constraintHeight_default="percent"
|
||||
app:layout_constraintHeight_percent="0.5" />
|
||||
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/iv_ripple"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:autoPlay="false"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintHeight_default="percent"
|
||||
app:layout_constraintHeight_percent="0.5"
|
||||
app:loopCount="0"
|
||||
app:source="ripple3695.svga" />
|
||||
|
||||
<!--头像框 - 比头像大2dp-->
|
||||
<com.xscm.moduleutil.widget.AvatarFrameView
|
||||
android:id="@+id/iv_frame"
|
||||
|
||||
Reference in New Issue
Block a user