diff --git a/app/build.gradle b/app/build.gradle index 058e476..2a42e8e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ android { ndk { //设置支持的so库 - abiFilters 'arm64-v8a', 'armeabi' -// abiFilters 'armeabi-v7a', 'arm64-v8a' +// abiFilters 'arm64-v8a', 'armeabi','arm64' + abiFilters 'arm64-v8a','armeabi-v7a' } javaCompileOptions { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a40b96c..e8660f2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -143,7 +143,6 @@ android:configChanges="orientation|keyboardHidden|screenSize" android:exported="true" android:screenOrientation="behind" - android:launchMode="singleTask" android:theme="@style/main_SplashThemeImage"> diff --git a/app/src/main/java/com/xscm/midi/LaunchPageActivity.java b/app/src/main/java/com/xscm/midi/LaunchPageActivity.java index 2c4042b..20d7961 100644 --- a/app/src/main/java/com/xscm/midi/LaunchPageActivity.java +++ b/app/src/main/java/com/xscm/midi/LaunchPageActivity.java @@ -25,9 +25,14 @@ public class LaunchPageActivity extends BaseAppCompatActivity { + // 点击“确认”按钮时执行 + finish(); + }, + v -> { + // 点击“取消”按钮时什么都不做 + + }, true, 0).show(); } + private void queren1() { + // 创建并显示确认对话框 + new ConfirmDialog(this, + "温馨提示", + "实名未通过,重新实名", + "确认", + "", + v -> { + // 点击“确认”按钮时执行 + finish(); + }, + v -> { + // 点击“取消”按钮时什么都不做 + + }, true, 0).show(); + } private void onClick(View view) { if (view.getId()== R.id.btnSubmit){ if (mBinding.edName.getText().toString().isEmpty()){ diff --git a/build.gradle b/build.gradle index 6a956ef..f6850d1 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,8 @@ buildscript { // ✅ 添加 ARouter 插件依赖 classpath 'com.alibaba:arouter-register:1.0.2' + +// classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin } } plugins { diff --git a/gradle.properties b/gradle.properties index f247d28..bcd66e1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,8 +29,8 @@ isBuildModule=false #org.gradle.deamon=false android.injected.testOnly=false -APP_VERSION_NAME=1.0.1 -APP_VERSION_CODE=130 +APP_VERSION_NAME=1.0.2 +APP_VERSION_CODE=144 org.gradle.jvm.toolchain.useLegacyAdapters=false #org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15 @@ -48,4 +48,7 @@ beta=false org.gradle.caching=false # ??APT???? -kapt.incremental.apt=false \ No newline at end of file +kapt.incremental.apt=false + +# 或者禁用特定模块的增量编译 +#org.gradle.configureondemand=false \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1165bd1..1ffcc9d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -163,4 +163,5 @@ android-library = { id = "com.android.library", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" } #kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlinVersion" } #alibaba-arouter = { id = "com.alibaba.arouter", version.ref = "arouter" } +greendao-plugin = { id = "org.greenrobot.greendao", version.ref = "greendaoGradlePlugin" } diff --git a/moduleLogin/src/main/res/layout/activity_improve_info.xml b/moduleLogin/src/main/res/layout/activity_improve_info.xml index 0174513..c6ce816 100644 --- a/moduleLogin/src/main/res/layout/activity_improve_info.xml +++ b/moduleLogin/src/main/res/layout/activity_improve_info.xml @@ -31,32 +31,51 @@ android:textStyle="bold" android:visibility="gone" /> - + + + + + + + + + android:layout_marginTop="@dimen/dp_34" + android:layout_marginRight="@dimen/dp_40"> + android:textStyle="bold" /> + android:textSize="14sp" /> @@ -102,6 +120,7 @@ android:layout_height="wrap_content" android:layout_marginLeft="@dimen/dp_40" android:orientation="horizontal"> + + + android:textSize="12sp" /> @@ -124,27 +143,25 @@ android:layout_width="match_parent" android:layout_height="@dimen/dp_72" android:layout_marginStart="@dimen/dp_40" - android:layout_marginEnd="@dimen/dp_40" android:layout_marginTop="12dp" - android:orientation="horizontal" - android:background="@drawable/selector_sex_mm"> + android:layout_marginEnd="@dimen/dp_40" + android:background="@drawable/selector_sex_mm" + android:orientation="horizontal"> + android:gravity="center"> + android:src="@mipmap/check_boy" /> + android:gravity="center"> + android:src="@mipmap/check_girl" /> @@ -174,6 +189,7 @@ android:layout_marginStart="@dimen/dp_40" android:layout_marginTop="@dimen/dp_24" android:orientation="horizontal"> + + android:textStyle="bold" /> @@ -220,49 +236,49 @@ + android:textStyle="bold" /> + android:textStyle="bold" /> + android:textStyle="bold" /> @@ -301,15 +317,14 @@ android:layout_width="match_parent" android:layout_height="@dimen/dp_42" android:layout_alignParentBottom="true" + android:layout_centerInParent="true" android:layout_centerHorizontal="true" android:layout_centerVertical="true" - android:layout_centerInParent="true" - android:background="@drawable/theme_bg" android:layout_marginLeft="@dimen/dp_40" android:layout_marginRight="@dimen/dp_40" android:layout_marginBottom="@dimen/dp_20" - android:gravity="center" - > + android:background="@drawable/theme_bg" + android:gravity="center"> + android:src="@drawable/theme_bg" + android:visibility="gone" /> + android:visibility="gone" /> + android:textSize="16sp" /> diff --git a/moduleUtil/build.gradle b/moduleUtil/build.gradle index 75aa285..5a7e832 100644 --- a/moduleUtil/build.gradle +++ b/moduleUtil/build.gradle @@ -207,7 +207,13 @@ dependencies { api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5' api 'io.github.mayzs:paho.mqtt.android:1.2.1' -// api project(':LocalAar') +// room数据库 +// def room_version = "2.5.0" +// implementation "androidx.room:room-runtime:$room_version" +// implementation "androidx.room:room-ktx:$room_version" +// annotationProcessor "androidx.room:room-compiler:$room_version" + + //2. 云normal SDK, //aar的名称,例如:WbCloudNormal-v5.1.10-123456789.aar,填入 'WbCloudNormal-v5.1.10-123456789.aar' diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/activity/BaseAppCompatActivity.java b/moduleUtil/src/main/java/com/xscm/moduleutil/activity/BaseAppCompatActivity.java index 3a5e83e..397d7f6 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/activity/BaseAppCompatActivity.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/activity/BaseAppCompatActivity.java @@ -54,7 +54,6 @@ 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 com.xscm.moduleutil.widget.PiaoPingManager; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -407,7 +406,7 @@ public abstract class BaseAppCompatActivity extends /// 礼物特效 // 在类中添加以下成员变量 - private final List mqttMessageQueue = new ArrayList<>(); // MQTT消息队列 + private final List mqttMessageQueue = new ArrayList<>(); // MQTT消息队列 private final List xlhMessageQueue = new ArrayList<>(); // XLH消息队列 private boolean isMqttPlaying = false; // MQTT播放状态标志 private boolean isXlhPlaying = false; // XLH播放状态标志 @@ -423,7 +422,8 @@ public abstract class BaseAppCompatActivity extends if (mqttBean == null) return; synchronized (mqttQueueLock) { - mqttMessageQueue.add(mqttBean); + + mqttMessageQueue.addAll(mqttBean.getList()); if (!isMqttPlaying) { isMqttPlaying = true; processNextMqttMessage(); @@ -448,7 +448,7 @@ public abstract class BaseAppCompatActivity extends // 处理下一个MQTT消息 private void processNextMqttMessage() { - MqttBean mqttBean; + MqttBean.ListBean mqttBean; synchronized (mqttQueueLock) { if (mqttMessageQueue.isEmpty()) { isMqttPlaying = false; @@ -475,7 +475,7 @@ public abstract class BaseAppCompatActivity extends ViewGroup decorView; ViewGroup decorView1; - private void showFloatingMessage(MqttBean mqttBean) { + private void showFloatingMessage(MqttBean.ListBean mqttBean) { try { // 清理之前的视图(如果存在) if (currentMqttView != null && currentMqttView.getParent() != null) { @@ -639,18 +639,18 @@ public abstract class BaseAppCompatActivity extends } } - private void updateFloatingViewData(View view, MqttBean mqttBean) { + private void updateFloatingViewData(View view, MqttBean.ListBean mqttBean) { TextView textView = view.findViewById(R.id.tv_name); TextView textView2 = view.findViewById(R.id.tv_to_name); TextView tv_time = view.findViewById(R.id.tv_num); - if (mqttBean.getList() != null) { - textView2.setText("送给" + (mqttBean.getList().getToUserName() != null ? mqttBean.getList().getToUserName() : "")); - textView.setText(mqttBean.getList().getFromUserName() != null ? mqttBean.getList().getFromUserName() : ""); - if (mqttBean.getList().getGift_picture() != null) { - ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), view.findViewById(R.id.iv_piaoping)); + if (mqttBean != null) { + textView2.setText("送给" + (mqttBean.getToUserName() != null ? mqttBean.getToUserName() : "")); + textView.setText(mqttBean.getFromUserName() != null ? mqttBean.getFromUserName() : ""); + if (mqttBean.getGift_picture() != null) { + ImageUtils.loadHeadCC(mqttBean.getGift_picture(), view.findViewById(R.id.iv_piaoping)); } - tv_time.setText("x" + (mqttBean.getList().getNumber() != null ? mqttBean.getList().getNumber() : "1")); + tv_time.setText("x" + (mqttBean.getNumber() != null ? mqttBean.getNumber() : "1")); } else { textView2.setText("送给"); textView.setText(""); diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/adapter/GiftTwoDetailsFragment.java b/moduleUtil/src/main/java/com/xscm/moduleutil/adapter/GiftTwoDetailsFragment.java index 1f709ba..ac123ea 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/adapter/GiftTwoDetailsFragment.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/adapter/GiftTwoDetailsFragment.java @@ -12,6 +12,7 @@ import com.xscm.moduleutil.R; import com.xscm.moduleutil.base.BaseMvpFragment; import com.xscm.moduleutil.bean.GiftLabelBean; import com.xscm.moduleutil.bean.GiftPackBean; +import com.xscm.moduleutil.bean.GiftPackEvent; import com.xscm.moduleutil.bean.GiftPackListCount; import com.xscm.moduleutil.bean.RewardUserBean; import com.xscm.moduleutil.bean.RoonGiftModel; @@ -79,6 +80,9 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment= Build.VERSION_CODES.M) { + Intent intent = new Intent(); + String packageName = getPackageName(); + PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); + if (pm != null && !pm.isIgnoringBatteryOptimizations(packageName)) { + intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); + intent.setData(Uri.parse("package:" + packageName)); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + try { + startActivity(intent); + } catch (Exception e) { + LogUtils.e("Failed to request battery optimization exemption: " + e.getMessage()); + } + } + } + } private void startActivityForResult(Intent intent, int i) { } diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/GiftPackEvent.java b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/GiftPackEvent.java new file mode 100644 index 0000000..203208c --- /dev/null +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/GiftPackEvent.java @@ -0,0 +1,8 @@ +package com.xscm.moduleutil.bean; + +import lombok.Data; + +@Data +public class GiftPackEvent { + private String bdid; +} diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/MqttXlhEnd.java b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/MqttXlhEnd.java new file mode 100644 index 0000000..964bcf6 --- /dev/null +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/MqttXlhEnd.java @@ -0,0 +1,8 @@ +package com.xscm.moduleutil.bean; + +import lombok.Data; + +@Data +public class MqttXlhEnd { + private String message; +} diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/MusicSongBean.java b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/MusicSongBean.java index 8edd22e..29dfa79 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/MusicSongBean.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/MusicSongBean.java @@ -13,7 +13,7 @@ public class MusicSongBean implements Serializable { private String did;//歌曲id private String room_id; - private String song_code;//歌曲唯一标识 + private String song_code="";//歌曲唯一标识 private String song_name;//歌曲名称 private String singer;//歌手 private String poster;//封面 diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/RoomMessageEvent.java b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/RoomMessageEvent.java index 96c9b8c..c9a48be 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/RoomMessageEvent.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/RoomMessageEvent.java @@ -35,6 +35,7 @@ public class RoomMessageEvent { private String jia_jia; private UserInfo FromUserInfo; private UserInfo ToUserInfo; + private List ToUserInfos; private GiftBean GiftInfo; private int room_up_pit_type; private MusicSongBean songInfo; @@ -52,7 +53,7 @@ public class RoomMessageEvent { private String AcceptRoomId;//接收者所在的房间id private String PkId; private String room_id;//当type==1的时候。这个roomId是对方的房间id - private String user_id; + private String user_id=""; private String pk_end_times;//pk结束时间 private List userCharmList; diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/ConfirmDialog.java b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/ConfirmDialog.java index 7482efd..a93ad15 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/ConfirmDialog.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/ConfirmDialog.java @@ -82,6 +82,7 @@ public class ConfirmDialog extends Dialog { // 设置点击监听器 btnPositive.setOnClickListener(v -> { + isCountdownCancelled = true; // 标记倒计时被取消 if (countDownTimer != null) { countDownTimer.cancel(); // 取消倒计时 countDownTimer = null; @@ -130,7 +131,7 @@ public class ConfirmDialog extends Dialog { // rootView.startAnimation(shake); // } } - + private boolean isCountdownCancelled = false; // 添加标志位 private void startCountdown(Button btnNegative) { countDownTimer = new CountDownTimer(countdownSeconds * 1000L, 1000) { @Override @@ -141,11 +142,14 @@ public class ConfirmDialog extends Dialog { @Override public void onFinish() { - btnNegative.setText(negativeButtonText); - if (negativeButtonClickListener != null) { - negativeButtonClickListener.onClick(btnNegative); // 自动触发取消 + // 检查是否被主动取消 + if (!isCountdownCancelled) { + btnNegative.setText(negativeButtonText); + if (negativeButtonClickListener != null) { + negativeButtonClickListener.onClick(btnNegative); // 自动触发取消 + } + dismiss(); } - dismiss(); } }.start(); } diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/WebViewDialog.java b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/WebViewDialog.java index f5f9d26..4e8e8bd 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/WebViewDialog.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/WebViewDialog.java @@ -80,6 +80,7 @@ public class WebViewDialog extends BaseDialog { if (type==10){ mBinding.gzCl.setBackgroundResource(R.mipmap.tkzj); mBinding.imGz.setImageResource(R.mipmap.tkzj_gz); + mBinding.webView.setPadding(16, 0, 16, 0); }else if (type==11){ mBinding.gzCl.setBackgroundResource(R.mipmap.syzc); mBinding.imGz.setImageResource(R.mipmap.syzc_gz); diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryDialog.java b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryDialog.java index ea9c04a..8d7241a 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryDialog.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryDialog.java @@ -373,7 +373,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment>() { @Override diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/TourClubDialogFragment.java b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/TourClubDialogFragment.java index a2f8bca..7965705 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/TourClubDialogFragment.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/TourClubDialogFragment.java @@ -1,46 +1,41 @@ package com.xscm.moduleutil.dialog.giftLottery; -import android.annotation.SuppressLint; import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.os.Bundle; import android.os.CountDownTimer; import android.os.Handler; import android.view.Gravity; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; -import android.widget.HorizontalScrollView; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearSnapHelper; import androidx.recyclerview.widget.RecyclerView; import com.alibaba.android.arouter.launcher.ARouter; -import com.blankj.utilcode.util.TimeUtils; +import com.blankj.utilcode.util.GsonUtils; import com.xscm.moduleutil.R; import com.xscm.moduleutil.base.BaseMvpDialogFragment; import com.xscm.moduleutil.bean.GiftBean; +import com.xscm.moduleutil.bean.MqttXlhEnd; import com.xscm.moduleutil.bean.RoomMessageEvent; import com.xscm.moduleutil.bean.WalletBean; +import com.xscm.moduleutil.bean.XLHBean; import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean; import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean; import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean; import com.xscm.moduleutil.databinding.FragmentTourClubDialogBinding; import com.xscm.moduleutil.dialog.WebViewDialog; +import com.xscm.moduleutil.event.MqttBean; import com.xscm.moduleutil.utils.ARouteConstants; import com.xscm.moduleutil.utils.ImageUtils; import com.xscm.moduleutil.widget.CenterScrollHelper; import com.xscm.moduleutil.widget.EqualSpaceItemDecoration; -import com.xscm.moduleutil.widget.InfintLinearLayoutManager; -import com.xscm.moduleutil.widget.pagerecyclerview.PagerGridSnapHelper; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -48,11 +43,11 @@ import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.List; -import java.util.Random; + /** - *@author qx - *@data 2025/9/15 - *@description: 玄镜之旅 + * @author qx + * @data 2025/9/15 + * @description: 玄镜之旅 */ public class TourClubDialogFragment extends BaseMvpDialogFragment implements GiftLotteryContacts.View { private String roomId; @@ -63,6 +58,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment data) { - isDrawing=false; + isDrawing = false; // 创建并显示对话框 - XlhObtainDialog dialog = new XlhObtainDialog(getActivity()); - dialog.setOnGiftItemClickListener(new XlhObtainDialog.OnGiftItemClickListener() { + // 关闭之前可能存在的对话框 +// if (xlhObtainDialog != null && xlhObtainDialog.isShowing()) { +// xlhObtainDialog.dismiss(); +// } + // 创建并显示对话框 + xlhObtainDialog = new XlhObtainDialog(getActivity()); + xlhObtainDialog.setOnGiftItemClickListener(new XlhObtainDialog.OnGiftItemClickListener() { @Override public void onPlayAgainClick() { - isDrawing=true; + isDrawing = true; // 处理再玩一次点击事件 MvpPre.xlhChou(roomId, num); } @@ -820,12 +842,15 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment { setCancelable(false); setCanceledOnTouchOutside(false); Window window = getWindow(); + // 设置对话框在屏幕中央显示 + window.setGravity(Gravity.CENTER); + // 去掉背景阴影 + window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); + + // 设置窗口背景为透明 + window.setBackgroundDrawableResource(android.R.color.transparent); window.setLayout((int) (ScreenUtils.getScreenWidth() * 375.f / 375), WindowManager.LayoutParams.WRAP_CONTENT); // 设置点击事件 mBinding.xlhClose.setOnClickListener(v -> { diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/event/MqttBean.java b/moduleUtil/src/main/java/com/xscm/moduleutil/event/MqttBean.java index ea76c88..29709d5 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/event/MqttBean.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/event/MqttBean.java @@ -1,5 +1,16 @@ package com.xscm.moduleutil.event; +import com.google.gson.Gson; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + import lombok.Data; /** @@ -10,7 +21,8 @@ import lombok.Data; @Data public class MqttBean { private String room_id; - private ListBean list; + @JsonAdapter(ListBeanListAdapter.class) + private List list; public String getRoom_id() { return room_id == null ? "" : room_id; @@ -20,14 +32,58 @@ public class MqttBean { this.room_id = room_id == null ? "" : room_id; } - public ListBean getList() { + public List getList() { return list; } - public void setList(ListBean list) { + public void setList(List list) { this.list = list; } + + // 自定义TypeAdapter来处理有时是对象有时是数组的情况 + public static class ListBeanListAdapter extends TypeAdapter> { + @Override + public void write(JsonWriter out, List value) throws IOException { + if (value == null) { + out.nullValue(); + return; + } + Gson gson = new Gson(); + out.beginArray(); + for (ListBean item : value) { + gson.toJson(item, ListBean.class, out); + } + out.endArray(); + } + + @Override + public List read(JsonReader in) throws IOException { + List list = new ArrayList<>(); + Gson gson = new Gson(); + + JsonToken token = in.peek(); + if (token == JsonToken.BEGIN_ARRAY) { + // 正常的数组情况 + in.beginArray(); + while (in.hasNext()) { + ListBean item = gson.fromJson(in, ListBean.class); + list.add(item); + } + in.endArray(); + } else if (token == JsonToken.BEGIN_OBJECT) { + // 单个对象的情况,转换为包含一个元素的列表 + ListBean item = gson.fromJson(in, ListBean.class); + list.add(item); + } else if (token == JsonToken.NULL) { + in.nextNull(); + } + // 其他情况(如字符串、数字等)直接跳过 + + return list; + } + } + @Data public static class ListBean { private String text; diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/http/BaseObserver.java b/moduleUtil/src/main/java/com/xscm/moduleutil/http/BaseObserver.java index 784fcc5..7b0c224 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/http/BaseObserver.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/http/BaseObserver.java @@ -55,6 +55,7 @@ public abstract class BaseObserver implements Observer { if (apiException.getCode() == 301) { EventBus.getDefault().post(new LogOutEvent()); try { + com.blankj.utilcode.util.ToastUtils.showShort("提示当前账号已在别的地方登陆,如果不是本人操作请修改密码"); CommonAppContext.getInstance().clearLoginInfo(); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/http/DefaultTransformer.java b/moduleUtil/src/main/java/com/xscm/moduleutil/http/DefaultTransformer.java index 30d61a9..19f62c4 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/http/DefaultTransformer.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/http/DefaultTransformer.java @@ -24,6 +24,7 @@ public class DefaultTransformer implements ObservableTransformer .map(response -> { if (response.isTokenExpired()) { // 触发登出事件(EventBus) + com.blankj.utilcode.util.ToastUtils.showShort("提示当前账号已在别的地方登陆,如果不是本人操作请修改密码"); CommonAppContext.getInstance().clearLoginInfo(); throw new APIException(-1, "登录已过期"); } diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/http/RetrofitClient.java b/moduleUtil/src/main/java/com/xscm/moduleutil/http/RetrofitClient.java index 80c87be..3a3d7cc 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/http/RetrofitClient.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/http/RetrofitClient.java @@ -315,6 +315,7 @@ public class RetrofitClient { observer.onNext(string.getData()); } else if (code == 301) { try { + ToastUtils.showShort("提示当前账号已在别的地方登陆,如果不是本人操作请修改密码"); CommonAppContext.getInstance().clearLoginInfo(); } catch (ClassNotFoundException e) { throw new RuntimeException(e); @@ -1994,7 +1995,7 @@ public class RetrofitClient { @Override public void onFailure(Call> call, Throwable t) { - ToastUtils.showShort(t.toString()); + ToastUtils.showShort("提示当前账号已在别的地方登陆,如果不是本人操作请修改密码"); if (t.toString().contains("登录失效")) { try { CommonAppContext.getInstance().clearLoginInfo(); @@ -2308,6 +2309,7 @@ public class RetrofitClient { } else if (code == 301) { try { + com.blankj.utilcode.util.ToastUtils.showShort("提示当前账号已在别的地方登陆,如果不是本人操作请修改密码"); CommonAppContext.getInstance().clearLoginInfo(); } catch (ClassNotFoundException e) { throw new RuntimeException(e); @@ -2360,7 +2362,14 @@ public class RetrofitClient { public void onResponse(Call>> call, Response>> response) { if (response.code() == 200) { BaseModel> baseModel = response.body(); - observer.onNext(baseModel.getData()); + if (baseModel.getCode()==1) { + if (baseModel != null && baseModel.getData() != null) { + observer.onNext(baseModel.getData()); + } + }else { + observer.onNext(null); + } + } } diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/listener/MessageListenerSingleton.java b/moduleUtil/src/main/java/com/xscm/moduleutil/listener/MessageListenerSingleton.java index 9a3e9ef..4914407 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/listener/MessageListenerSingleton.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/listener/MessageListenerSingleton.java @@ -42,6 +42,7 @@ public class MessageListenerSingleton { private V2TIMSimpleMsgListener simpleMsgListener; private V2TIMAdvancedMsgListener v2TIMAdvancedMsgListener; private static String mRoomId = ""; + public static String groupId; private V2TIMGroupListener groupListener; private V2TIMConversationListener conversationListener; // 需要保存引用 @@ -80,17 +81,22 @@ public class MessageListenerSingleton { // 修改 joinGroup 方法 public void joinGroup(String roomId) { - mRoomId = roomId; + LogUtils.e("@@@", "加入房间的"+roomId); + + if (groupId!=null){ + quitGroup(groupId); + } // 确保监听器已初始化并添加 ensureListenersAdded(); // RoomMessageEvent.T t = new RoomMessageEvent.T(); // t.setText("羽声严禁未成年人进行直播或打赏,官方将24小时在线巡查。我们提倡绿色直播,直播间严禁出现涉政、涉恐、涉黄、涉赌等违法违规内容,严禁宣传封建迷信、宗教极端思想、出现低俗色情、吸烟酗酒等内容,严禁违反社会主义核心价值观、践踏社会道德底线、诱导打赏、低俗 PK 、买卖金币等行为,请大家共同遵守、监督并及时举报。请勿相信各类刷钻、购买礼包、游戏币及电商贩卖等非官方广告信息,谨防网络诈骗。"); // notifyMessageReceived(new RoomMessageEvent(1000, mRoomId, t)); - V2TIMManager.getInstance().joinGroup("room" + mRoomId, "申请加入", new V2TIMCallback() { + V2TIMManager.getInstance().joinGroup("room" + roomId, "申请加入", new V2TIMCallback() { @Override public void onSuccess() { Log.d("@@@", "加入im群组成功:"); + groupId = roomId; } @Override @@ -290,6 +296,16 @@ public class MessageListenerSingleton { // 修改 quitGroup 方法 public static void quitGroup(String mRoomId) { + + if (instance != null) { + instance.listeners.clear(); + removeAllListeners(); + isInitialized = false; + groupId=null; +// instance = null; + LogUtils.e("@@@","重置成功"); + } + V2TIMManager.getInstance().quitGroup("room" + mRoomId, new V2TIMCallback() { @Override public void onSuccess() { @@ -311,6 +327,7 @@ public class MessageListenerSingleton { instance.listeners.clear(); removeAllListeners(); isInitialized = false; + groupId=null; // instance = null; quitGroup(roomId); LogUtils.e("@@@","重置成功"); diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/rtc/AgoraIsOPen.java b/moduleUtil/src/main/java/com/xscm/moduleutil/rtc/AgoraIsOPen.java new file mode 100644 index 0000000..ece2b68 --- /dev/null +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/rtc/AgoraIsOPen.java @@ -0,0 +1,13 @@ +package com.xscm.moduleutil.rtc; + +import lombok.Data; + +/** + *@author qx + *@data 2025/9/18 + *@description: 加入声网返回 + */ +@Data +public class AgoraIsOPen { + private boolean isOpen; +} diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/rtc/AgoraManager.java b/moduleUtil/src/main/java/com/xscm/moduleutil/rtc/AgoraManager.java index 4e4e0db..7e9f868 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/rtc/AgoraManager.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/rtc/AgoraManager.java @@ -1,6 +1,7 @@ package com.xscm.moduleutil.rtc; +import static com.blankj.utilcode.util.SnackbarUtils.getView; import static io.agora.rtc2.video.VideoEncoderConfiguration.FRAME_RATE.FRAME_RATE_FPS_15; import static io.agora.rtc2.video.VideoEncoderConfiguration.ORIENTATION_MODE.ORIENTATION_MODE_ADAPTIVE; import static io.agora.rtc2.video.VideoEncoderConfiguration.STANDARD_BITRATE; @@ -77,7 +78,7 @@ public class AgoraManager { // private RtcEngineEx rtcEngineEx; private static Context context; private boolean isLocalAudioEnabled = true; // 默认开启麦克风 - private final List eventHandlers = new ArrayList<>(); + // private final List eventHandlers = new ArrayList<>(); private static IAgoraMusicContentCenter musicContentCenter; private static IAgoraMusicPlayer musicPlayer; private static MusicContentCenterConfiguration contentCenterConfiguration; @@ -87,16 +88,16 @@ public class AgoraManager { private static List musicList; private static boolean isBjMusic = false; private static List soundLevelUpdateListeners = new CopyOnWriteArrayList<>(); - private static ChannelMediaOptions options; - private static RtcConnection connection; + private static ChannelMediaOptions options; + private static RtcConnection connection; private String pkRoomId = ""; private static String lastRoomId; - public void setLastRoomId(String value) { + public void setLastRoomId(String value) { lastRoomId = value; } - public String getLastRoomId() { + public String getLastRoomId() { LogUtils.e("上次的房间id:" + lastRoomId); return lastRoomId; } @@ -112,13 +113,20 @@ public class AgoraManager { synchronized (AgoraManager.class) { if (instance == null) { instance = new AgoraManager(); - context = con; + context = con.getApplicationContext(); // 使用ApplicationContext避免内存泄漏 // init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); // init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); } } } - + // 确保引擎已初始化 + if (rtcEngine == null) { + synchronized (AgoraManager.class) { + if (rtcEngine == null) { + init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); + } + } + } return instance; } @@ -142,62 +150,75 @@ public class AgoraManager { * 初始化 Agora 引擎 */ public static void init(String appId) { - if (rtcEngine != null) throw new IllegalStateException("RtcEngine已经初始化过");; - - try { - RtcEngineConfig config = new RtcEngineConfig(); - config.mContext = context; - config.mAppId = appId; - config.mEventHandler = getDefaultEventHandler(); - config.mChannelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING; - config.mAudioScenario = Constants.AUDIO_SCENARIO_CHORUS; - - config.mAudioScenario = Constants.AudioScenario.getValue(Constants.AudioScenario.DEFAULT); - config.mAreaCode = 1; - - rtcEngine = (RtcEngineEx) RtcEngine.create(config); - } catch (Exception e) { - Log.e("AgoraManager", "Failed to create RtcEngine", e); - } - if (rtcEngine != null) { - rtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO, - Constants.AUDIO_SCENARIO_GAME_STREAMING); - rtcEngine.enableAudioVolumeIndication(200, 3, true); - rtcEngine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER); -// rtcEngine.enableLocalAudio(false); // 启用/禁用音频采集 - rtcEngine.muteLocalAudioStream(true); // 默认静音 - rtcEngine.muteAllRemoteAudioStreams(false);//监听远端的音频 - rtcEngine.setParameters("{\"che.audio.custom_payload_type\":73}"); - rtcEngine.setParameters("{\"che.audio.custom_bitrate\":128000}"); - rtcEngine.setParameters("{\"rtc.enable_nasa2\": true}"); - rtcEngine.setParameters("{\"rtc.use_audio4\": true}"); - rtcEngine.setParameters("{" - + "\"rtc.report_app_scenario\":" - + "{" - + "\"appScenario\":" + 100 + "," - + "\"serviceType\":" + 11 + "," - + "\"appVersion\":\"" + RtcEngine.getSdkVersion() + "\"" - + "}" - + "}"); - - - rtcEngine.setParameters("{\"che.video.mobile_1080p\":true}"); - - /*Enable video module*/ - rtcEngine.enableVideo(); - // Setup video encoding configs - rtcEngine.setVideoEncoderConfiguration(new VideoEncoderConfiguration( - VD_640x360, - FRAME_RATE_FPS_15, - STANDARD_BITRATE, - ORIENTATION_MODE_ADAPTIVE - )); - /*Set up to play remote sound with receiver*/ - rtcEngine.setDefaultAudioRoutetoSpeakerphone(true); + return; } + ; -// return this; + synchronized (AgoraManager.class) { + if (rtcEngine != null) { + return; + } + + try { + RtcEngineConfig config = new RtcEngineConfig(); + config.mContext = context; + config.mAppId = appId; + config.mEventHandler = getDefaultEventHandler(); + config.mChannelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING; + config.mAudioScenario = Constants.AUDIO_SCENARIO_CHORUS; + config.mAreaCode = 1; + + rtcEngine = (RtcEngineEx) RtcEngine.create(config); + } catch (Exception e) { + Log.e("AgoraManager", "Failed to create RtcEngine", e); + return; + } + + if (rtcEngine != null) { + try { + rtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO, + Constants.AUDIO_SCENARIO_GAME_STREAMING); + rtcEngine.enableAudioVolumeIndication(200, 3, true); + rtcEngine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER); + rtcEngine.muteLocalAudioStream(true); // 默认静音 + rtcEngine.muteAllRemoteAudioStreams(false); // 监听远端的音频 + + // 设置参数时添加异常处理 + try { + rtcEngine.setParameters("{\"che.audio.custom_payload_type\":73}"); + rtcEngine.setParameters("{\"che.audio.custom_bitrate\":128000}"); + rtcEngine.setParameters("{\"rtc.enable_nasa2\": true}"); + rtcEngine.setParameters("{\"rtc.use_audio4\": true}"); + rtcEngine.setParameters("{" + + "\"rtc.report_app_scenario\":" + + "{" + + "\"appScenario\":" + 100 + "," + + "\"serviceType\":" + 11 + "," + + "\"appVersion\":\"" + RtcEngine.getSdkVersion() + "\"" + + "}" + + "}"); + rtcEngine.setParameters("{\"che.video.mobile_1080p\":true}"); + } catch (Exception e) { + Log.w("AgoraManager", "Failed to set parameters", e); + } + + /*Enable video module*/ + rtcEngine.enableVideo(); + // Setup video encoding configs + rtcEngine.setVideoEncoderConfiguration(new VideoEncoderConfiguration( + VD_640x360, + FRAME_RATE_FPS_15, + STANDARD_BITRATE, + ORIENTATION_MODE_ADAPTIVE + )); + /*Set up to play remote sound with receiver*/ + rtcEngine.setDefaultAudioRoutetoSpeakerphone(true); + } catch (Exception e) { + Log.e("AgoraManager", "Failed to configure RtcEngine", e); + } + } + } } /** @@ -233,295 +254,115 @@ public class AgoraManager { // setLocalAudioEnabled(false); this.isLocalAudioEnabled = isMicrophoneEnabled; + } - - public void potexao(String page) { - rtcEngine.playEffect(1, page, 0, 1, 0, 100, true); - } - - /** - * 离开房间 - */ - public void leaveRoom() { - if (rtcEngine != null) { - rtcEngine.leaveChannel(); - } - } - - public void joinChannelEx(String token, String channelId, int uid) { - if (rtcEngine == null) { - init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); - } - if (rtcEngine != null) { - options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER; - options.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING; - options.publishMicrophoneTrack = true; // 是否发布麦克风音频 - options.enableAudioRecordingOrPlayout = true; - options.autoSubscribeAudio = true; - connection = new RtcConnection(); - connection.channelId = channelId; - connection.localUid = uid; - pkRoomId = channelId; - rtcEngine.joinChannelEx(token, connection, options, getDefaultEventHandler()); - } - } - - public void leaveChannelEx(String mRoomId, int uid) { - if (rtcEngine != null) { - RtcConnection connection = new RtcConnection(); - connection.channelId = mRoomId; - connection.localUid = uid; - rtcEngine.leaveChannelEx(connection); - } - } - - public void updateChannelMediaOptions() { - - if (rtcEngine != null) { - options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER; -// options.autoSubscribeVideo = true; -// options.autoSubscribeAudio = true; -//// 不发布摄像头采集的视频 -// options.publishCameraTrack = false; -//// 不发布麦克风采集的视频 -// options.publishMicrophoneTrack = false; -//// 在频道中发布屏幕采集的视频 -// options.publishScreenCaptureVideo = true; -//// 在频道中发布屏幕采集的音频 -// options.publishScreenCaptureAudio = true; - rtcEngine.setScreenCaptureScenario(Constants.ScreenScenarioType.SCREEN_SCENARIO_VIDEO); - rtcEngine.updateChannelMediaOptions(options); - } - } - - public void post() { - if (rtcEngine != null) { -// rtcEngine.setParameters("{\"che.video.mobile_1080p\":true}"); -// rtcEngine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER); -// -// /*Enable video module*/ -// rtcEngine.enableVideo(); -// // Setup video encoding configs -// rtcEngine.setVideoEncoderConfiguration(new VideoEncoderConfiguration( -// VD_640x360, -// FRAME_RATE_FPS_15, -// STANDARD_BITRATE, -// ORIENTATION_MODE_ADAPTIVE -// )); -// /*Set up to play remote sound with receiver*/ -// rtcEngine.setDefaultAudioRoutetoSpeakerphone(true); - - ScreenCaptureParameters screenCaptureParameters = new ScreenCaptureParameters(); - screenCaptureParameters.captureVideo = true; - screenCaptureParameters.videoCaptureParameters.width = 720; - screenCaptureParameters.videoCaptureParameters.height = 920; - screenCaptureParameters.videoCaptureParameters.framerate = 15; - screenCaptureParameters.captureAudio = true; - screenCaptureParameters.audioCaptureParameters.captureSignalVolume = 50; - - rtcEngine.startScreenCapture(screenCaptureParameters); - } - } - - public void isMute(int index) { - if (rtcEngine != null) { - } - } - - public void selectAudioTrack(int index) { - if (musicPlayer != null) { - musicPlayer.selectAudioTrack(index); - } - } - - /** - * 销毁引擎 - */ /** * 清理资源但保留实例 */ public void cleanup() { - if (rtcEngine != null) { - // 停止屏幕捕获 - rtcEngine.stopScreenCapture(); + try { + if (rtcEngine != null) { +// // 离开频道 - // 停止预览 - rtcEngine.stopPreview(); + rtcEngine.leaveChannel(); - // 离开频道 - rtcEngine.leaveChannel(); + if (musicContentCenter != null) { + musicPlayer.unRegisterPlayerObserver(null); + musicPlayer.stop(); + musicContentCenter.destroyMusicPlayer(musicPlayer); + musicPlayer = null; + musicContentCenter.unregisterEventHandler(); + musicContentCenter = null; + IAgoraMusicContentCenter.destroy(); - // 销毁音乐播放器 - if (musicPlayer != null) { - musicPlayer.stop(); - musicPlayer.destroy(); - musicPlayer = null; - } - - // 销毁音乐内容中心 - if (musicContentCenter != null) { - musicContentCenter.destroy(); - musicContentCenter = null; - } - - // 移除所有事件监听器 - for (IRtcEngineEventHandler handler : eventHandlers) { - rtcEngine.removeHandler(handler); - } - eventHandlers.clear(); - } - - // 清理静态变量 - musicList = null; - soundLevelUpdateListeners.clear(); - mRoomId = ""; - mSongCode = 0; - options = null; - connection = null; - pkRoomId = ""; - isBjMusic = false; - } - - /** - * 完全销毁实例(只在应用退出时调用) - */ - public void destroy() { - cleanup(); - // 只有在应用完全退出时才置空实例 - instance = null; - - // 如果需要销毁 RtcEngine,在这里进行 - if (rtcEngine != null) { - RtcEngine.destroy(); - rtcEngine = null; - } - } - - - public void desMusic() { - if (musicPlayer != null) { - musicPlayer.stop(); - } - } - - /** - * 设置是否开启本地麦克风 - */ - @SuppressLint("SuspiciousIndentation") - public void setLocalAudioEnabled(boolean enabled, String userId) { - if (rtcEngine != null) { - if (userId != null) { - if (userId.equals(SpUtil.getUserId() + "")) { - rtcEngine.enableLocalAudio(enabled); // 启用/禁用音频采集 - } - this.isLocalAudioEnabled = enabled; - if (!enabled) { - for (SoundLevelUpdateListener listener : soundLevelUpdateListeners) { - if (listener != null) { - ThreadUtils.runOnUiThread(() -> { - // 远程用户音量变化 - listener.onRemoteSoundLevelUpdate(userId, 0); - }); - } - } } +// RtcEngine.destroy(); +// rtcEngine = null; + + // 销毁音乐播放器 +// if (musicContentCenter != null) { +// if (musicPlayer != null) { +// try { +// musicPlayer.stop(); +// musicContentCenter.destroyMusicPlayer(musicPlayer); +// musicPlayer.destroy(); +//// musicPlayer.unRegisterPlayerObserver(null); +// } catch (Exception e) { +// Log.w("AgoraManager", "Error destroying music player", e); +// } +// musicPlayer = null; +// } +// +// try { +// musicContentCenter.unregisterEventHandler(); +// IAgoraMusicContentCenter.destroy(); +// } catch (Exception e) { +// Log.w("AgoraManager", "Error unregistering event handler", e); +// +// } +// musicContentCenter = null; +// } + +//// 移除所有事件监听器 +// for (IRtcEngineEventHandler handler : eventHandlers) { +// try { +// rtcEngine.removeHandler(handler); +// } catch (Exception e) { +// Log.w("AgoraManager", "Error removing handler", e); +// } +// } +// eventHandlers.clear(); + + // 停止屏幕捕获 +// try { +//// rtcEngine.stopScreenCapture(); +// } catch (Exception e) { +// Log.w("AgoraManager", "Error stopping screen capture", e); +// } +// +// // 停止预览 +// try { +//// rtcEngine.stopPreview(); +// } catch (Exception e) { +// Log.w("AgoraManager", "Error stopping preview", e); +// } +// +// try { +// rtcEngine.leaveChannel(); +// } catch (Exception e) { +// Log.w("AgoraManager", "Error leaving channel", e); +// } } + } catch (Exception e) { + Log.e("AgoraManager", "Error during cleanup", e); + } finally { + // 注意:不要在这里将rtcEngine设置为null + // 应该在destroy方法中处理 + + // 清理静态变量 + musicList = null; + soundLevelUpdateListeners.clear(); + mRoomId = ""; + mSongCode = 0; + options = null; + connection = null; + pkRoomId = ""; + isBjMusic = false; + isOnJoin = false; } } - public void muteAllRemoteAudioStreamsEx(boolean enabled) { - if (rtcEngine == null) { - init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); - } - if (rtcEngine != null) { -// RtcConnection connection = new RtcConnection(); -// connection.channelId = mRoomId; - if (connection == null) { - connection = new RtcConnection(); - connection.channelId = pkRoomId; - } - rtcEngine.muteAllRemoteAudioStreamsEx(enabled, connection); - } + private static boolean isOnJoin = false; + + public boolean isOnJoin() { + return isOnJoin; } - //设置是否是主播角色 - public void ClientRole(boolean enabled) { - if (rtcEngine != null) { - rtcEngine.setClientRole(enabled ? Constants.CLIENT_ROLE_BROADCASTER : Constants.CLIENT_ROLE_AUDIENCE); - } else { - init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); - rtcEngine.setClientRole(enabled ? Constants.CLIENT_ROLE_BROADCASTER : Constants.CLIENT_ROLE_AUDIENCE); - } + public void setOnJoin(boolean onJoin) { + isOnJoin = onJoin; } - /** - * 启用或者关闭远端音频流 - * - * @param enabled - * @param uid - */ - public void muteLocalAudioStreamEx(boolean enabled, int uid) { -// RtcConnection connection = new RtcConnection(); -// connection.channelId = mRoomId; -// connection.localUid = uid; - if (rtcEngine == null) { - init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); - } - // 正确做法 - rtcEngine.muteLocalAudioStreamEx(enabled, connection); - } - - /** - * 启用/关闭本地音频流 - * - * @param enabled - */ - public void muteLocalAudioStream(boolean enabled) { - if (rtcEngine != null) { - rtcEngine.muteLocalAudioStream(enabled); // 静音/取消静音 - } else { - init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); - rtcEngine.muteLocalAudioStream(enabled); // 静音/取消静音 - } - } - - /** - * 设置是否开启背景音乐推流(不影响播放) - */ - public void setMusicStreamEnabled(boolean enabled) { - if (musicPlayer != null) { - musicPlayer.adjustPublishSignalVolume(enabled ? 50 : 0); - } - } - - - /** - * 获取当前麦克风状态 - */ - public boolean isLocalAudioEnabled() { - return isLocalAudioEnabled; - } - - /** - * 添加事件监听器(用于全局回调) - */ - public void addEventHandler(IRtcEngineEventHandler handler) { - if (handler != null && !eventHandlers.contains(handler)) { - eventHandlers.add(handler); - } - } - - /** - * 移除事件监听器 - */ - public void removeEventHandler(IRtcEngineEventHandler handler) { - if (handler != null) { - eventHandlers.remove(handler); - } - } - - /** * 默认事件处理器,转发给所有监听器 */ @@ -529,6 +370,13 @@ public class AgoraManager { return new IRtcEngineEventHandler() { @Override public void onJoinChannelSuccess(String channel, int uid, int elapsed) { + + if (!isOnJoin) { + AgoraIsOPen isOPen = new AgoraIsOPen(); + isOPen.setOpen(true); + EventBus.getDefault().post(isOPen); + isOnJoin = true; + } musicContentCenter = IAgoraMusicContentCenter.create(rtcEngine); contentCenterConfiguration = new MusicContentCenterConfiguration(); // 已开启音乐内容中心项目的 App ID @@ -537,20 +385,71 @@ public class AgoraManager { contentCenterConfiguration.mccUid = uid; // 填入用于鉴权的 Token contentCenterConfiguration.token = SpUtil.getRtmToken(); + // 创建 IAgoraMusicContentCenterEventHandler,用于 SDK 向客户端发送音乐内容中心事件通知 - contentCenterConfiguration.eventHandler = new IMusicContentCenterEventHandler() { +// contentCenterConfiguration.eventHandler = new IMusicContentCenterEventHandler() { +// @Override +// public void onPreLoadEvent(String requestId, long songCode, int percent, String lyricUrl, int status, int errorCode) { +// LogUtils.e("@@@1", "requestId: " + requestId + ", songCode: " + songCode + ", percent: " + percent + ", lyricUrl: " + lyricUrl + ", status: " + status + ", errorCode: " + errorCode); +// if (!lyricUrl.isEmpty() && percent == 100 && !isBjMusic) { +// getLyricsInstance(lyricUrl); +// } +//// musicPlayer.open(songCode, 0); +// } +// +// @Override +// public void onMusicCollectionResult(String requestId, int page, int pageSize, int total, Music[] list, int errorCode) { +// LogUtils.e("@@@2", "requestId: " + requestId + ", page: " + page + ", pageSize: " + pageSize + ", total: " + total); +// MusicBean musicBean = new MusicBean(); +// musicBean.setMusicList(Arrays.asList(list)); +// musicBean.setPage(page); +// EventBus.getDefault().post(musicBean); +// } +// +// @Override +// public void onMusicChartsResult(String requestId, MusicChartInfo[] list, int errorCode) { +// LogUtils.e("@@@", "requestId: " + requestId); +// } +// +// @Override +// public void onLyricResult(String requestId, long songCode, String lyricUrl, int errorCode) { +// LogUtils.e("@@@22", "requestId: " + requestId + ", songCode: " + songCode + ", lyricUrl: " + lyricUrl + ", errorCode: " + errorCode); +// if (lyricUrl != null && !isBjMusic) { +// getLyricsInstance(lyricUrl); +// } +// } +// +// @Override +// public void onSongSimpleInfoResult(String requestId, long songCode, String simpleInfo, int errorCode) { +// LogUtils.e("@@@", "requestId: " + requestId + ", songCode: " + songCode + ", simpleInfo: " + simpleInfo + ", errorCode: " + errorCode); +// } +// }; +// 初始化 IAgoraMusicContentCenter + + musicContentCenter.initialize(contentCenterConfiguration); + if (musicPlayer != null) { + musicPlayer = null; + } + musicPlayer = musicContentCenter.createMusicPlayer(); + musicContentCenter.registerEventHandler(new IMusicContentCenterEventHandler() { @Override - public void onPreLoadEvent(String requestId, long songCode, int percent, String lyricUrl, int status, int errorCode) { - LogUtils.e("@@@1", "requestId: " + requestId + ", songCode: " + songCode + ", percent: " + percent + ", lyricUrl: " + lyricUrl + ", status: " + status + ", errorCode: " + errorCode); - if (!lyricUrl.isEmpty() && percent == 100 && !isBjMusic) { - getLyricsInstance(lyricUrl); + public void onPreLoadEvent(String requestId, long songCode, int percent, String lyricUrl, int state, int reason) { + if (percent == 100) { + musicPlayer.stop(); + musicPlayer.open(songCode, 0); +// getLyricsInstance(lyricUrl); } -// musicPlayer.open(songCode, 0); + LogUtils.e("AgoraManager", "isPreload2: " + songCode); + +// if (!lyricUrl.isEmpty() && percent == 100 && !isBjMusic) { +// musicPlayer.stop(); +// musicPlayer.open(songCode, 0); +//// getLyricsInstance(lyricUrl); +// } } @Override - public void onMusicCollectionResult(String requestId, int page, int pageSize, int total, Music[] list, int errorCode) { - LogUtils.e("@@@2", "requestId: " + requestId + ", page: " + page + ", pageSize: " + pageSize + ", total: " + total); + public void onMusicCollectionResult(String requestId, int page, int pageSize, int total, Music[] list, int reason) { MusicBean musicBean = new MusicBean(); musicBean.setMusicList(Arrays.asList(list)); musicBean.setPage(page); @@ -558,60 +457,70 @@ public class AgoraManager { } @Override - public void onMusicChartsResult(String requestId, MusicChartInfo[] list, int errorCode) { - LogUtils.e("@@@", "requestId: " + requestId); + public void onMusicChartsResult(String requestId, MusicChartInfo[] list, int reason) { + } @Override - public void onLyricResult(String requestId, long songCode, String lyricUrl, int errorCode) { - LogUtils.e("@@@22", "requestId: " + requestId + ", songCode: " + songCode + ", lyricUrl: " + lyricUrl + ", errorCode: " + errorCode); - if (lyricUrl != null && !isBjMusic) { + public void onLyricResult(String requestId, long songCode, String lyricUrl, int reason) { + if (lyricUrl != null) { getLyricsInstance(lyricUrl); } } @Override - public void onSongSimpleInfoResult(String requestId, long songCode, String simpleInfo, int errorCode) { - LogUtils.e("@@@", "requestId: " + requestId + ", songCode: " + songCode + ", simpleInfo: " + simpleInfo + ", errorCode: " + errorCode); + public void onSongSimpleInfoResult(String requestId, long songCode, String simpleInfo, int reason) { + } - }; -// 初始化 IAgoraMusicContentCenter - musicContentCenter.initialize(contentCenterConfiguration); - musicPlayer = musicContentCenter.createMusicPlayer(); + }); + + musicPlayer.registerPlayerObserver(new IMediaPlayerObserver() { @Override public void onPlayerStateChanged(io.agora.mediaplayer.Constants.MediaPlayerState state, io.agora.mediaplayer.Constants.MediaPlayerReason reason) { + + if (state == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_OPEN_COMPLETED) { + if (isBjMusic) { + return; + } musicContentCenter.getLyric(mSongCode, 1); musicContentCenter.getSongSimpleInfo(mSongCode); } else if (state == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED) { - nextSong(); +// nextSong(); } LogUtils.e("@@@", "state: " + state); } @Override - public void onPositionChanged(long positionMs, long timestampMs) { - MusicPlayBean musicPlayBean = new MusicPlayBean(); - musicPlayBean.setPosition(positionMs); - EventBus.getDefault().post(musicPlayBean); - if (!isBjMusic) { - String S = GsonUtils.toJson(musicPlayBean); - LogUtils.e("@@", S); - RoomMessageEvent.T t = new RoomMessageEvent.T(); - t.setText(S); - RoomMessageEvent roomMessageEvent = new RoomMessageEvent(124, mRoomId, t); - String json = GsonUtils.toJson(roomMessageEvent); - // 转换为 byte[] - byte[] binaryData = json.getBytes(StandardCharsets.UTF_8); - // 创建自定义消息 - MessageListenerSingleton.getInstance().sendCustomRoomMessage( - mRoomId, - binaryData - ); + public void onPositionChanged(long positionMs, long timestampMs) {//播放进度 + if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PLAYING) { + MusicPlayBean musicPlayBean = new MusicPlayBean(); + musicPlayBean.setPosition(positionMs); + EventBus.getDefault().post(musicPlayBean); + + if (!isBjMusic) { + String S = GsonUtils.toJson(musicPlayBean); + LogUtils.e("@@", S); + RoomMessageEvent.T t = new RoomMessageEvent.T(); + t.setText(S); + RoomMessageEvent roomMessageEvent = new RoomMessageEvent(124, mRoomId, t); + String json = GsonUtils.toJson(roomMessageEvent); + // 转换为 byte[] + byte[] binaryData = json.getBytes(StandardCharsets.UTF_8); + // 创建自定义消息 + MessageListenerSingleton.getInstance().sendCustomRoomMessage( + mRoomId, + binaryData + ); + } + } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED) { + if (isBjMusic) { + nextSong(); + } } } @@ -812,6 +721,252 @@ public class AgoraManager { }; } + public void potexao(String page) { + rtcEngine.playEffect(1, page, 0, 1, 0, 100, true); + } + + /** + * 离开房间 + */ + public void leaveRoom() { + if (rtcEngine != null) { + rtcEngine.leaveChannel(); + mSongCode = 0; + } + } + + public void joinChannelEx(String token, String channelId, int uid) { + if (rtcEngine == null) { + init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); + } + if (rtcEngine != null) { + options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER; + options.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING; + options.publishMicrophoneTrack = true; // 是否发布麦克风音频 + options.enableAudioRecordingOrPlayout = true; + options.autoSubscribeAudio = true; + connection = new RtcConnection(); + connection.channelId = channelId; + connection.localUid = uid; + pkRoomId = channelId; + rtcEngine.joinChannelEx(token, connection, options, getDefaultEventHandler()); + + + } + } + + public void leaveChannelEx(String mRoomId, int uid) { + if (rtcEngine != null) { + RtcConnection connection = new RtcConnection(); + connection.channelId = mRoomId; + connection.localUid = uid; + rtcEngine.leaveChannelEx(connection); + } + } + + public void updateChannelMediaOptions() { + + if (rtcEngine != null) { + options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER; +// options.autoSubscribeVideo = true; +// options.autoSubscribeAudio = true; +//// 不发布摄像头采集的视频 +// options.publishCameraTrack = false; +//// 不发布麦克风采集的视频 +// options.publishMicrophoneTrack = false; +//// 在频道中发布屏幕采集的视频 +// options.publishScreenCaptureVideo = true; +//// 在频道中发布屏幕采集的音频 +// options.publishScreenCaptureAudio = true; + rtcEngine.setScreenCaptureScenario(Constants.ScreenScenarioType.SCREEN_SCENARIO_VIDEO); + rtcEngine.updateChannelMediaOptions(options); + } + } + + public void post() { + if (rtcEngine != null) { +// rtcEngine.setParameters("{\"che.video.mobile_1080p\":true}"); +// rtcEngine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER); +// +// /*Enable video module*/ +// rtcEngine.enableVideo(); +// // Setup video encoding configs +// rtcEngine.setVideoEncoderConfiguration(new VideoEncoderConfiguration( +// VD_640x360, +// FRAME_RATE_FPS_15, +// STANDARD_BITRATE, +// ORIENTATION_MODE_ADAPTIVE +// )); +// /*Set up to play remote sound with receiver*/ +// rtcEngine.setDefaultAudioRoutetoSpeakerphone(true); + + ScreenCaptureParameters screenCaptureParameters = new ScreenCaptureParameters(); + screenCaptureParameters.captureVideo = true; + screenCaptureParameters.videoCaptureParameters.width = 720; + screenCaptureParameters.videoCaptureParameters.height = 920; + screenCaptureParameters.videoCaptureParameters.framerate = 15; + screenCaptureParameters.captureAudio = true; + screenCaptureParameters.audioCaptureParameters.captureSignalVolume = 50; + + rtcEngine.startScreenCapture(screenCaptureParameters); + } + } + + public void isMute(int index) { + if (rtcEngine != null) { + } + } + + public void selectAudioTrack(int index) { + if (musicPlayer != null) { + musicPlayer.selectAudioTrack(index); + } + } + + public void stopMusicPlayer() { + if (musicPlayer != null) { + musicPlayer.stop(); + } + } + + + /** + * 完全销毁实例(只在应用退出时调用) + */ + public void destroy() { + cleanup(); + // 只有在应用完全退出时才置空实例 + instance = null; + + // 如果需要销毁 RtcEngine,在这里进行 + if (rtcEngine != null) { + RtcEngine.destroy(); + rtcEngine = null; + } + } + + + public void desMusic() { + if (musicPlayer != null) { + musicPlayer.stop(); + } + } + + /** + * 设置是否开启本地麦克风 + */ + @SuppressLint("SuspiciousIndentation") + public void setLocalAudioEnabled(boolean enabled, String userId) { + if (rtcEngine != null) { + if (userId != null) { + if (userId.equals(SpUtil.getUserId() + "")) { + rtcEngine.enableLocalAudio(enabled); // 启用/禁用音频采集 + } + this.isLocalAudioEnabled = enabled; + if (!enabled) { + for (SoundLevelUpdateListener listener : soundLevelUpdateListeners) { + if (listener != null) { + ThreadUtils.runOnUiThread(() -> { + // 远程用户音量变化 + listener.onRemoteSoundLevelUpdate(userId, 0); + }); + } + } + } + } + } + } + + public void muteAllRemoteAudioStreamsEx(boolean enabled) { + if (rtcEngine == null) { + init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); + } + if (rtcEngine != null) { +// RtcConnection connection = new RtcConnection(); +// connection.channelId = mRoomId; + if (connection == null) { + connection = new RtcConnection(); + connection.channelId = pkRoomId; + } + rtcEngine.muteAllRemoteAudioStreamsEx(enabled, connection); + } + } + + //设置是否是主播角色 + public void ClientRole(boolean enabled) { + if (rtcEngine != null) { + rtcEngine.setClientRole(enabled ? Constants.CLIENT_ROLE_BROADCASTER : Constants.CLIENT_ROLE_AUDIENCE); + } else { + init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); + rtcEngine.setClientRole(enabled ? Constants.CLIENT_ROLE_BROADCASTER : Constants.CLIENT_ROLE_AUDIENCE); + } + } + + /** + * 启用或者关闭远端音频流 + * + * @param enabled + * @param uid + */ + public void muteLocalAudioStreamEx(boolean enabled, int uid) { +// RtcConnection connection = new RtcConnection(); +// connection.channelId = mRoomId; +// connection.localUid = uid; + if (rtcEngine == null) { + init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); + } + // 正确做法 + rtcEngine.muteLocalAudioStreamEx(enabled, connection); + } + + /** + * 启用/关闭本地音频流 + * + * @param enabled + */ + public void muteLocalAudioStream(boolean enabled) { + if (rtcEngine != null) { + rtcEngine.muteLocalAudioStream(enabled); // 静音/取消静音 + } else { + init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); + rtcEngine.muteLocalAudioStream(enabled); // 静音/取消静音 + } + } + + /** + * 设置是否开启背景音乐推流(不影响播放) + */ + public void setMusicStreamEnabled(boolean enabled) { + if (musicPlayer != null) { + musicPlayer.adjustPublishSignalVolume(enabled ? 50 : 0); + } + } + + + /** + * 获取当前麦克风状态 + */ + public boolean isLocalAudioEnabled() { + return isLocalAudioEnabled; + } + + /** + * 添加事件监听器(用于全局回调) + */ +// public void addEventHandler(IRtcEngineEventHandler handler) { +// if (handler != null && !eventHandlers.contains(handler)) { +// eventHandlers.add(handler); +// } +// } + + /** + * 移除事件监听器 + */ +// public void removeEventHandler(IRtcEngineEventHandler handler) { +// if (handler != null) { +// eventHandlers.remove(handler); +// } +// } public void addSoundLevelListener(SoundLevelUpdateListener listener) { if (soundLevelUpdateListeners != null) { soundLevelUpdateListeners.add(listener); @@ -839,216 +994,285 @@ public class AgoraManager { * type:2:别人进入后 */ public void isPreload(long songCode, int type) { - mSongCode = songCode; - int code; - if (musicContentCenter == null) { - musicContentCenter = IAgoraMusicContentCenter.create(rtcEngine); - } - if (musicPlayer == null) { - musicPlayer = musicContentCenter.createMusicPlayer(); + LogUtils.e("AgoraManager", "isPreload: " + songCode); + // 确保 rtcEngine 已初始化 + if (rtcEngine == null) { + Log.e("AgoraManager", "RtcEngine not initialized, cannot preload music"); + init(CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId()); + return; + } + + // 初始化 musicContentCenter 如果为 null + if (musicContentCenter == null) { + try { + musicContentCenter = IAgoraMusicContentCenter.create(rtcEngine); + if (musicContentCenter == null) { + Log.e("AgoraManager", "Failed to create musicContentCenter"); + return; + } + } catch (Exception e) { + Log.e("AgoraManager", "Exception creating musicContentCenter", e); + return; + } + } + + // 初始化 musicPlayer 如果为 null + if (musicPlayer == null) { + try { + musicPlayer = musicContentCenter.createMusicPlayer(); + if (musicPlayer == null) { + Log.e("AgoraManager", "Failed to create musicPlayer"); + return; + } + } catch (Exception e) { + Log.e("AgoraManager", "Exception creating musicPlayer", e); + return; + } + } + + int code; + try { + code = musicContentCenter.isPreloaded(mSongCode); + } catch (Exception e) { + Log.e("AgoraManager", "Exception checking if song is preloaded", e); + return; } -// musicContentCenter.preload(songCode); - code = musicContentCenter.isPreloaded(mSongCode); if (type == 1) { if (code < 0) { - // 创建定时器,3秒后再次检查 - new Handler(Looper.getMainLooper()).postDelayed(() -> { - musicContentCenter.preload(mSongCode); - isPreload(mSongCode, type); - }, 3000); // 3秒延迟 - } else { - if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PAUSED) {//暂停 - LogUtils.e("lxj", "暂停"); - musicPlayer.resume(); - - } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_IDLE) {//空闲 - LogUtils.e("lxj", "空闲"); - musicPlayer.open(mSongCode, 0); - new Handler(Looper.getMainLooper()).postDelayed(() -> { - isPreload(mSongCode, type); - }, 2000); // 2秒延迟 -// isPreload(mSongCode, type); - } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_OPEN_COMPLETED) {//打开成功 - LogUtils.e("lxj", "播放"); - musicPlayer.play(); - musicPlayer.selectAudioTrack(0); - } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_IDLE) { - LogUtils.e("lxj", "空闲"); - musicPlayer.open(mSongCode, 0); - isPreload(mSongCode, type); -// LogUtils.e("@@@", musicPlayer.getState()); -// musicPlayer.pause() ; - } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PAUSING_INTERNAL) { - LogUtils.e("lxj", "关闭"); - musicPlayer.pause(); - } 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()); - isPreload(mSongCode, type); - } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PLAYING) { - LogUtils.e("lxj", musicPlayer.getState()); - isPreload(mSongCode, type); - } - } - } else if (type == 2) { - if (code < 0) { + String result = musicContentCenter.preload(mSongCode); // 创建定时器,3秒后再次检查 new Handler(Looper.getMainLooper()).postDelayed(() -> { try { - musicContentCenter.preload(mSongCode); + Log.d("AgoraManager", "Preload result: " + result); isPreload(mSongCode, type); } catch (Exception e) { - Log.e("lxj", "预加载歌曲失败: songCode=" + mSongCode, e); + Log.e("AgoraManager", "Preload song failed: songCode=" + mSongCode, e); } }, 3000); // 3秒延迟 } else { - musicPlayer.open(mSongCode, 0); -// if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PAUSED) {//暂停 -// LogUtils.e("lxj", "暂停"); -// musicPlayer.resume(); -// -// } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_IDLE) {//空闲 -// LogUtils.e("lxj", "空闲"); -// musicPlayer.open(mSongCode, 0); -// isPreload(mSongCode, type); -// } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_OPEN_COMPLETED) {//打开成功 -// LogUtils.e("lxj", "播放"); -// musicPlayer.play(); -// musicPlayer.selectAudioTrack(0); -// } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_IDLE) { -// LogUtils.e("lxj", "空闲"); -// musicPlayer.open(mSongCode, 0); -// isPreload(mSongCode, type); -//// LogUtils.e("@@@", musicPlayer.getState()); -//// musicPlayer.pause() ; -// } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PAUSING_INTERNAL) { -// LogUtils.e("lxj", "关闭"); -// musicPlayer.pause(); -// } 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()); -// isPreload(mSongCode, type); -// } + handleMusicPlayerState(songCode); + } + } else if (type == 2) { + if (code < 0) { + String result = musicContentCenter.preload(mSongCode); + // 创建定时器,3秒后再次检查 + new Handler(Looper.getMainLooper()).postDelayed(() -> { + try { + Log.d("AgoraManager", "Preload result: " + result); + isPreload(mSongCode, type); + } catch (Exception e) { + Log.e("AgoraManager", "Preload song failed: songCode=" + mSongCode, e); + } + }, 3000); // 3秒延迟 + } else { + try { + musicPlayer.open(mSongCode, 0); + } catch (Exception e) { + Log.e("AgoraManager", "Open music failed: songCode=" + mSongCode, e); + } } } + } + // 提取音乐播放器状态处理逻辑到单独的方法 + private void handleMusicPlayerState(long songCode) { + if (musicPlayer == null) { + Log.e("AgoraManager", "Music player is null, cannot handle state"); + return; + } + + try { + io.agora.mediaplayer.Constants.MediaPlayerState state = musicPlayer.getState(); + switch (state) { + case PLAYER_STATE_PAUSED: + LogUtils.e("lxj", "暂停"); + musicPlayer.resume(); + break; + case PLAYER_STATE_IDLE: + LogUtils.e("lxj", "空闲"); + musicPlayer.open(songCode, 0); + new Handler(Looper.getMainLooper()).postDelayed(() -> { + isPreload(songCode, 1); + }, 2000); // 2秒延迟 + break; + case PLAYER_STATE_OPEN_COMPLETED: + LogUtils.e("lxj", "播放"); + musicPlayer.play(); + musicPlayer.selectAudioTrack(0);//播放原生 + break; + case PLAYER_STATE_PAUSING_INTERNAL: + LogUtils.e("lxj", "关闭"); + musicPlayer.pause(); + break; + case PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED: + LogUtils.e("lxj", "daki"); + musicPlayer.open(songCode, 0); + isPreload(songCode, 1); + break; + case PLAYER_STATE_OPENING: + LogUtils.e("lxj", state.toString()); +// isPreload(songCode, 1); + break; + case PLAYER_STATE_PLAYING: + LogUtils.e("lxj", state.toString()); + isPreload(songCode, 1); + break; + case PLAYER_STATE_STOPPED: + LogUtils.e("lxj", "停止"); + musicPlayer.open(songCode, 0); + isPreload(songCode, 1); + break; + default: + LogUtils.e("lxj", "未知状态: " + state); + break; + } + } catch (Exception e) { + Log.e("AgoraManager", "Exception handling music player state", e); + } } public static void isPreload2(long songCode, int type) { - - mSongCode = songCode; - int code; + + // 确保 rtcEngine 已初始化 + if (rtcEngine == null) { + Log.e("AgoraManager", "RtcEngine not initialized, cannot preload music"); + return; + } + + // 初始化 musicContentCenter 如果为 null if (musicContentCenter == null) { - musicContentCenter = IAgoraMusicContentCenter.create(rtcEngine); + try { + musicContentCenter = IAgoraMusicContentCenter.create(rtcEngine); + if (musicContentCenter == null) { + Log.e("AgoraManager", "Failed to create musicContentCenter"); + return; + } + } catch (Exception e) { + Log.e("AgoraManager", "Exception creating musicContentCenter", e); + return; + } } + + // 初始化 musicPlayer 如果为 null if (musicPlayer == null) { - musicPlayer = musicContentCenter.createMusicPlayer(); + try { + musicPlayer = musicContentCenter.createMusicPlayer(); + if (musicPlayer == null) { + Log.e("AgoraManager", "Failed to create musicPlayer"); + return; + } + } catch (Exception e) { + Log.e("AgoraManager", "Exception creating musicPlayer", e); + return; + } } -// setMusicStreamEnabled(true); -// musicContentCenter.preload(songCode); - code = musicContentCenter.isPreloaded(mSongCode); + + int code; + try { + code = musicContentCenter.isPreloaded(mSongCode); + } catch (Exception e) { + Log.e("AgoraManager", "Exception checking if song is preloaded", e); + return; + } + if (type == 1) { if (code < 0) { // 创建定时器,3秒后再次检查 new Handler(Looper.getMainLooper()).postDelayed(() -> { - musicContentCenter.preload(mSongCode); - isPreload2(mSongCode, type); + try { + String result = musicContentCenter.preload(mSongCode); + Log.d("AgoraManager", "Preload result: " + result); + isPreload2(mSongCode, type); + } catch (Exception e) { + Log.e("AgoraManager", "Preload song failed: songCode=" + mSongCode, e); + } }, 3000); // 3秒延迟 } else { - if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PAUSED) {//暂停 - LogUtils.e("lxj", "暂停"); - musicPlayer.resume(); - - } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_IDLE) {//空闲 - LogUtils.e("lxj", "空闲"); - musicPlayer.open(mSongCode, 0); - new Handler(Looper.getMainLooper()).postDelayed(() -> { - isPreload2(mSongCode, type); - }, 3000); // 3秒延迟 -// isPreload2(mSongCode, type); - } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_OPEN_COMPLETED) {//打开成功 - LogUtils.e("lxj", "播放"); - musicPlayer.play(); - musicPlayer.selectAudioTrack(0); - } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_IDLE) { - LogUtils.e("lxj", "空闲"); - musicPlayer.open(mSongCode, 0); - new Handler(Looper.getMainLooper()).postDelayed(() -> { - isPreload2(mSongCode, type); - }, 3000); // 3秒延迟 -// isPreload2(mSongCode, type); -// LogUtils.e("@@@", musicPlayer.getState()); -// musicPlayer.pause() ; - } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PAUSING_INTERNAL) { - LogUtils.e("lxj", "关闭"); - musicPlayer.pause(); - } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED) { - LogUtils.e("lxj", "daki"); - musicPlayer.open(mSongCode, 0); - isPreload2(mSongCode, type); - } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_OPENING) { - LogUtils.e("lxj", musicPlayer.getState()); - isPreload2(mSongCode, type); - } + handleMusicPlayerState2(songCode); } } else if (type == 2) { if (code < 0) { // 创建定时器,3秒后再次检查 new Handler(Looper.getMainLooper()).postDelayed(() -> { try { - musicContentCenter.preload(mSongCode); + String result = musicContentCenter.preload(mSongCode); + Log.d("AgoraManager", "Preload result: " + result); isPreload2(mSongCode, type); } catch (Exception e) { - Log.e("@@@", "预加载歌曲失败: songCode=" + mSongCode, e); + Log.e("AgoraManager", "Preload song failed: songCode=" + mSongCode, e); } }, 3000); // 3秒延迟 } else { - musicPlayer.open(mSongCode, 0); -// if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PAUSED) {//暂停 -// LogUtils.e("lxj", "暂停"); -// musicPlayer.resume(); -// -// } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_IDLE) {//空闲 -// LogUtils.e("lxj", "空闲"); -// musicPlayer.open(mSongCode, 0); -// isPreload2(mSongCode, type); -// } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_OPEN_COMPLETED) {//打开成功 -// LogUtils.e("lxj", "播放"); -// musicPlayer.play(); -// musicPlayer.selectAudioTrack(0); -// } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_IDLE) { -// LogUtils.e("lxj", "空闲"); -// musicPlayer.open(mSongCode, 0); -// isPreload2(mSongCode, type); -//// LogUtils.e("@@@", musicPlayer.getState()); -//// musicPlayer.pause() ; -// } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PAUSING_INTERNAL) { -// LogUtils.e("lxj", "关闭"); -// musicPlayer.pause(); -// } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED) { -// LogUtils.e("lxj", "daki"); -// musicPlayer.open(mSongCode, 0); -// isPreload2(mSongCode, type); -// } else if (musicPlayer.getState() == io.agora.mediaplayer.Constants.MediaPlayerState.PLAYER_STATE_OPENING) { -// LogUtils.e("lxj", musicPlayer.getState()); -// isPreload2(mSongCode, type); -// } + try { + musicPlayer.open(mSongCode, 0); + } catch (Exception e) { + Log.e("AgoraManager", "Open music failed: songCode=" + mSongCode, e); + } } } - } + // 提取音乐播放器状态处理逻辑到单独的方法 + private static void handleMusicPlayerState2(long songCode) { + if (musicPlayer == null) { + Log.e("AgoraManager", "Music player is null, cannot handle state"); + return; + } + + try { + io.agora.mediaplayer.Constants.MediaPlayerState state = musicPlayer.getState(); + switch (state) { + case PLAYER_STATE_PAUSED: + LogUtils.e("lxj", "暂停"); + musicPlayer.resume(); + break; + case PLAYER_STATE_IDLE: + LogUtils.e("lxj", "空闲"); + musicPlayer.open(songCode, 0); + new Handler(Looper.getMainLooper()).postDelayed(() -> { + isPreload2(songCode, 1); + }, 3000); // 3秒延迟 + break; + case PLAYER_STATE_OPEN_COMPLETED: + LogUtils.e("lxj", "播放"); + musicPlayer.play(); + musicPlayer.selectAudioTrack(0); + break; + case PLAYER_STATE_PAUSING_INTERNAL: + LogUtils.e("lxj", "关闭"); + musicPlayer.pause(); + break; + case PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED: + LogUtils.e("lxj", "daki"); + musicPlayer.open(songCode, 0); + isPreload2(songCode, 1); + break; + case PLAYER_STATE_OPENING: + LogUtils.e("lxj", state.toString()); +// isPreload2(songCode, 1); + break; + case PLAYER_STATE_PLAYING: + LogUtils.e("lxj", state.toString()); + isPreload2(songCode, 1); + break; + case PLAYER_STATE_STOPPED: + LogUtils.e("lxj", state.toString()); + isPreload2(songCode, 1); + break; + default: + LogUtils.e("lxj", "未知状态: " + state); + break; + } + } catch (Exception e) { + Log.e("AgoraManager", "Exception handling music player state", e); + } + } + + public void play() { musicPlayer.play(); } @@ -1195,37 +1419,6 @@ public class AgoraManager { */ public static void getLyricsInstance(String lrcUri) { downloadAndPlayMp4(lrcUri); - - -// final File[] file = new File[1]; -//// 设置可缓存的歌词文件的最大数量,默认为 50 -// LyricsFileDownloader.getInstance(context).setMaxFileNum(50); -//// 设置单个歌词文件的有效期,默认为 8 小时 -// LyricsFileDownloader.getInstance(context).setMaxFileAge(8 * 60 * 60); -// LyricsFileDownloader.getInstance(context).download(lrcUri); -// LyricsFileDownloader.getInstance(context).setLyricsFileDownloaderCallback(new LyricsFileDownloaderCallback() { -// // 歌词文件下载回调 -// @Override -// public void onLyricsFileDownloadProgress(int requestId, float progress) { -// LogUtils.e("onLyricsFileDownloadProgress", "requestId: " + requestId + ", progress: " + progress); -// MusicFileBean musicFileBean = new MusicFileBean(); -// musicFileBean.setFileData(null); -// EventBus.getDefault().post(musicFileBean); -// } -// -// // 歌词文件下载完成回调 -// @Override -// public void onLyricsFileDownloadCompleted(int requestId, byte[] fileData, DownloadError error) { -// LogUtils.e("onLyricsFileDownloadCompleted", "requestId: " + requestId + ", error: " + error); -// if (error == null) { -// MusicFileBean musicFileBean = new MusicFileBean(); -// musicFileBean.setFileData(fileData); -// EventBus.getDefault().post(musicFileBean); -// } -// -// } -// }); - } private static void downloadAndPlayMp4(String url) { @@ -1278,6 +1471,18 @@ public class AgoraManager { } } + public void loadLrc(long songCode) { + mSongCode = songCode; + if (musicContentCenter != null) { + int code = musicContentCenter.isPreloaded(songCode); + if (code < 0) { + musicContentCenter.preload(songCode); + } else { + musicPlayer.open(songCode, 0); + } + } + } + public static byte[] convertFileToByteArray(File file) { byte[] byteArray = null; try (FileInputStream fis = new FileInputStream(file)) { diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/service/EMqttService.java b/moduleUtil/src/main/java/com/xscm/moduleutil/service/EMqttService.java deleted file mode 100644 index 2fdf831..0000000 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/service/EMqttService.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.xscm.moduleutil.service; - - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ObjectAnimator; -import android.app.Service; -import android.content.Intent; -import android.graphics.PixelFormat; -import android.os.Build; -import android.os.IBinder; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewTreeObserver; -import android.view.WindowManager; -import android.widget.TextView; - - -import com.xscm.moduleutil.R; -import com.xscm.moduleutil.event.MqttBean; -import com.xscm.moduleutil.utils.ImageUtils; - - -public class EMqttService extends Service { - private WindowManager windowManager; - private View piaoPingView; - - @Override - public void onCreate() { - super.onCreate(); - windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); - } - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - if (intent != null && intent.hasExtra("mqttBean")) { - MqttBean mqttBean = (MqttBean) intent.getSerializableExtra("mqttBean"); - showPiaoPingMessage(mqttBean);//全局飘屏 - } - return START_NOT_STICKY; - } - - @Override - public void onDestroy() { - super.onDestroy(); - if (piaoPingView != null) { - windowManager.removeView(piaoPingView); - } - } - - @Override - public IBinder onBind(Intent intent) { - return null; - } - - public void showPiaoPingMessage(MqttBean mqttBean) { - - int screenWidth = getResources().getDisplayMetrics().widthPixels; - int screenHeight = getResources().getDisplayMetrics().heightPixels; -// - WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams( - WindowManager.LayoutParams.MATCH_PARENT, - WindowManager.LayoutParams.WRAP_CONTENT, - Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? - WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY : - WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, - WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | - WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | - WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, - PixelFormat.TRANSLUCENT); -// -// // 设置 Gravity 为左上角 -// layoutParams.gravity = Gravity.TOP | Gravity.START; -// -// // Y 轴随机位置 -// layoutParams.y = (int) ((Math.random() * (screenHeight - 200))); -// -// // 初始 X 设为负值,确保 View 在屏幕左侧外 -// layoutParams.x = -screenWidth; - -// FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( -// FrameLayout.LayoutParams.MATCH_PARENT, -// FrameLayout.LayoutParams.WRAP_CONTENT); -// - - // 设置随机 Y 轴位置 -// layoutParams.topMargin = (int) (Math.random() * (screenHeight - 200)); - - - piaoPingView = LayoutInflater.from(this).inflate(R.layout.item_piaoping, null); - TextView textView = piaoPingView.findViewById(R.id.tv_name); - textView.setText(mqttBean.getList().getText()); - ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), piaoPingView.findViewById(R.id.iv_piaoping)); - TextView tv_time = piaoPingView.findViewById(R.id.tv_num); - tv_time.setText(mqttBean.getList().getNumber()); - windowManager.addView(piaoPingView, layoutParams); - - piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this); - - // 设置锚点为左上角,避免偏移干扰 - piaoPingView.setPivotX(0); - piaoPingView.setPivotY(0); - - // 启动动画:从左外滑入 -> 右外滑出 - ObjectAnimator animator = ObjectAnimator.ofFloat( - piaoPingView, - "translationX", - 0f, // 初始偏移为 0(此时 View 在左侧外) - screenWidth // 向右移动整个屏幕宽度 - ); - animator.setDuration(2000); // 整个动画的时长为2秒 - - // 强制 GPU 渲染 - piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null); - - // 延迟显示2秒后开始滑出屏幕的动画 - piaoPingView.postDelayed(new Runnable() { - @Override - public void run() { - animator.start(); - } - }, 2000); - - animator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - windowManager.removeView(piaoPingView); - stopSelf(); - } - }); - } - }); - } -} - diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/service/FloatingWindow.java b/moduleUtil/src/main/java/com/xscm/moduleutil/service/FloatingWindow.java deleted file mode 100644 index f27ef36..0000000 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/service/FloatingWindow.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.xscm.moduleutil.service; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ObjectAnimator; -import android.content.Context; -import android.graphics.PixelFormat; -import android.os.Build; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewTreeObserver; -import android.view.WindowManager; -import android.widget.TextView; - -import com.xscm.moduleutil.R; -import com.xscm.moduleutil.event.MqttBean; -import com.xscm.moduleutil.utils.ImageUtils; - -/** - *@author qx - *@data 2025/8/8 - *@description: 全局悬浮框管理类 - */ -public class FloatingWindow { - private WindowManager windowManager; - private View piaoPingView; - - public FloatingWindow(Context context, MqttBean mqttBean){ - int screenWidth =context.getResources().getDisplayMetrics().widthPixels; - windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); - piaoPingView = LayoutInflater.from(context).inflate(R.layout.item_piaoping, null); - WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams( - WindowManager.LayoutParams.WRAP_CONTENT, - WindowManager.LayoutParams.WRAP_CONTENT, - - Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? - WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY : - WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, - WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | - WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | - WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, - - PixelFormat.TRANSLUCENT); - - - TextView textView = piaoPingView.findViewById(R.id.tv_name); - textView.setText(mqttBean.getList().getText()); - ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), piaoPingView.findViewById(R.id.iv_piaoping)); - TextView tv_time = piaoPingView.findViewById(R.id.tv_num); - tv_time.setText(mqttBean.getList().getNumber()); - windowManager.addView(piaoPingView, layoutParams); - -// piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { -// @Override -// public void onGlobalLayout() { -// piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this); -// -// // 设置锚点为左上角,避免偏移干扰 -// piaoPingView.setPivotX(0); -// piaoPingView.setPivotY(0); -// -// // 启动动画:从左外滑入 -> 右外滑出 -// ObjectAnimator animator = ObjectAnimator.ofFloat( -// piaoPingView, -// "translationX", -// 0f, // 初始偏移为 0(此时 View 在左侧外) -// screenWidth // 向右移动整个屏幕宽度 -// ); -// animator.setDuration(2000); // 整个动画的时长为2秒 -// -// // 强制 GPU 渲染 -// piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null); -// -// // 延迟显示2秒后开始滑出屏幕的动画 -// piaoPingView.postDelayed(new Runnable() { -// @Override -// public void run() { -// animator.start(); -// } -// }, 2000); -// -// animator.addListener(new AnimatorListenerAdapter() { -// @Override -// public void onAnimationEnd(Animator animation) { -// windowManager.removeView(piaoPingView); -// stopSelf(); -// } -// }); -// } -// }); - - - piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this); - - // 获取视图宽度 - int viewWidth = piaoPingView.getWidth(); - - // 设置锚点为左上角 - piaoPingView.setPivotX(0); - piaoPingView.setPivotY(0); - - // 强制 GPU 渲染 - piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null); - - // 创建滑入动画:从左外滑入到屏幕左侧 - ObjectAnimator slideInAnimator = ObjectAnimator.ofFloat( - piaoPingView, - "translationX", - -viewWidth, // 起始位置:屏幕左外 - 0f // 结束位置:屏幕左边缘 - ); - slideInAnimator.setDuration(500); // 滑入动画时长0.5秒 - - // 创建滑出动画:从当前位置滑出到屏幕右侧外 - ObjectAnimator slideOutAnimator = ObjectAnimator.ofFloat( - piaoPingView, - "translationX", - 0f, // 起始位置:屏幕左边缘 - screenWidth // 结束位置:屏幕右外 - ); - slideOutAnimator.setDuration(500); // 滑出动画时长0.5秒 - - // 设置滑出动画监听器 - slideOutAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - windowManager.removeView(piaoPingView); - stopSelf(); - } - }); - - // 开始执行动画序列 - slideInAnimator.start(); - - // 滑入完成后延迟2秒执行滑出动画 - piaoPingView.postDelayed(new Runnable() { - @Override - public void run() { - slideOutAnimator.start(); - } - }, 2000); - } - }); - - } - - public void stopSelf(){ - if (piaoPingView != null) { - windowManager.removeView(piaoPingView); - piaoPingView = null; - } - } -} diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/service/MqttInitCallback.java b/moduleUtil/src/main/java/com/xscm/moduleutil/service/MqttInitCallback.java index e973e6e..5b48b95 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/service/MqttInitCallback.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/service/MqttInitCallback.java @@ -7,10 +7,13 @@ import android.util.Log; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.blankj.utilcode.util.GsonUtils; import com.hjq.toast.ToastUtils; import com.orhanobut.logger.Logger; +import com.xscm.moduleutil.bean.MqttXlhEnd; import com.xscm.moduleutil.bean.XLHBean; import com.xscm.moduleutil.event.RoomGiftRunable; +import com.xscm.moduleutil.utils.SpUtil; import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; import org.eclipse.paho.client.mqttv3.MqttCallback; @@ -78,6 +81,18 @@ public class MqttInitCallback implements MqttCallback { case 5019://推送所有人-横幅礼物通知 new RoomGiftRunable(message).run(); break; + case 8000: + XLHBean xlhBean= GsonUtils.fromJson(message, XLHBean.class); + if (xlhBean!=null && xlhBean.getRoom_id()!=null && SpUtil.getMyRoomId()!=null) { + if (xlhBean.getRoom_id().equals(SpUtil.getMyRoomId())) { + MqttXlhEnd mqttXlhEnd = new MqttXlhEnd(); + mqttXlhEnd.setMessage(message); + EventBus.getDefault().post(mqttXlhEnd); + } + } + break; + default: + break; } } @@ -89,7 +104,7 @@ public class MqttInitCallback implements MqttCallback { XLHBean xlhBean=JSON.parseObject(message, XLHBean.class); // 将事件处理放到主线程执行 new Handler(Looper.getMainLooper()).post(() -> { -// processMessageType(type, message); + processMessageType(type, message); EventBus.getDefault().post(xlhBean); }); } catch (Exception e) { diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/BaseWheatView.java b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/BaseWheatView.java index c75244e..a0294af 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/BaseWheatView.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/BaseWheatView.java @@ -143,6 +143,8 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe } + + /** * 设置麦位数据 * diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/GiftAnimView.java b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/GiftAnimView.java index e27f2cd..81d9fde 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/GiftAnimView.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/GiftAnimView.java @@ -83,10 +83,12 @@ public class GiftAnimView extends FrameLayout implements GiftSvgaView.OnAnimatio public void onVideoComplete() { LogUtils.e("onVideoComplete"); post(() -> { - playerMp4View.setVisibility(View.GONE); - // 通知播放完成 - notifyPlaybackComplete(); - loadStartSVGAPlayer(); + if (playerMp4View!=null) { + playerMp4View.setVisibility(View.GONE); + // 通知播放完成 + notifyPlaybackComplete(); + loadStartSVGAPlayer(); + } }); } @@ -415,7 +417,9 @@ public class GiftAnimView extends FrameLayout implements GiftSvgaView.OnAnimatio @Override public void onFinishedDisplay(GiftSvgaView view) { post(() -> { - svgaView.setVisibility(View.GONE); + if (svgaView!=null) { + svgaView.setVisibility(View.GONE); + } // 通知播放完成 notifyPlaybackComplete(); loadStartSVGAPlayer(); diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/PiaoPingManager.java b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/PiaoPingManager.java deleted file mode 100644 index db22c4e..0000000 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/PiaoPingManager.java +++ /dev/null @@ -1,322 +0,0 @@ -package com.xscm.moduleutil.widget; - - -import static android.app.PendingIntent.getActivity; -import static android.content.Context.WINDOW_SERVICE; -import static androidx.core.content.ContextCompat.getSystemService; - -import static com.blankj.utilcode.util.ActivityUtils.startActivityForResult; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ObjectAnimator; -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.Intent; -import android.graphics.PixelFormat; -import android.os.Build; -import android.provider.Settings; -import android.view.LayoutInflater; -import android.view.View; -import android.view.WindowManager; -import android.view.animation.DecelerateInterpolator; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.TextView; - -import com.alibaba.android.arouter.launcher.ARouter; -import com.blankj.utilcode.util.LogUtils; -import com.hjq.toast.ToastUtils; -import com.petterp.floatingx.FloatingX; -import com.petterp.floatingx.assist.FxGravity; -import com.petterp.floatingx.assist.FxScopeType; -import com.petterp.floatingx.assist.helper.FxAppHelper; -import com.xscm.moduleutil.R; -import com.xscm.moduleutil.activity.BaseAppCompatActivity; -import com.xscm.moduleutil.bean.XLHBean; -import com.xscm.moduleutil.event.MqttBean; -import com.xscm.moduleutil.utils.ARouteConstants; -import com.xscm.moduleutil.utils.ImageUtils; - -import org.greenrobot.eventbus.EventBus; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * @Author - * @Time 2025/7/18 21:52 - * @Description 飘屏管理器 - */ -public class PiaoPingManager { - private static PiaoPingManager instance; - private WindowManager windowManager; - private View piaoPingView; - private boolean isPiaoPingShown = false; - private Queue messageQueue = new ConcurrentLinkedQueue<>(); // 消息队列 - private Queue XLHmessageQueue = new ConcurrentLinkedQueue<>(); // 消息队列 - private boolean isAnimating = false; // 动画状态标记 - private boolean XLHisAnimating = false; // 动画状态标记 - - private Context mContext; // 添加成员变量 - View floatingView; - - private PiaoPingManager(Context context) { - this.mContext = context; - windowManager = (WindowManager) context.getSystemService(WINDOW_SERVICE); - if (windowManager == null) return; - - // 创建飘屏消息的布局 - LayoutInflater inflater = LayoutInflater.from(context); - piaoPingView = inflater.inflate(R.layout.item_piaoping, null); - - } - - public static synchronized PiaoPingManager getInstance(Context context) { - if (instance == null) { - instance = new PiaoPingManager(context.getApplicationContext()); - } - return instance; - } - - public void showPiaoPingMessage(MqttBean mqttBean) { - // 创建 FloatingX 配置 - // 添加到队列 - messageQueue.offer(mqttBean); - // 如果当前没有动画正在进行,则开始处理 -// if (!isAnimating) { - processNextMessage(); -// } - - } - - private void processNextMessage() { - if (messageQueue.isEmpty()) { - isAnimating = false; - return; - } - - isAnimating = true; - MqttBean mqttBean = messageQueue.poll(); - - displayMessage(mqttBean); - - - } - - private void displayMessage(MqttBean mqttBean) { -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { -// WindowManager.LayoutParams params = new WindowManager.LayoutParams( -// WindowManager.LayoutParams.WRAP_CONTENT, -// WindowManager.LayoutParams.WRAP_CONTENT, -// WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, -// WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, -// PixelFormat.TRANSLUCENT -// ); - - - ToastUtils.show("飘屏开始"); - // 获取悬浮窗视图并设置内容 - floatingView = LayoutInflater.from(mContext).inflate(R.layout.item_piaoping, new FrameLayout(mContext), false); - TextView textView = floatingView.findViewById(R.id.tv_name); - TextView textView2 = floatingView.findViewById(R.id.tv_to_name); - textView2.setText("送给" + mqttBean.getList().getToUserName()); - textView.setText(mqttBean.getList().getFromUserName()); - ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), floatingView.findViewById(R.id.iv_piaoping)); - TextView tv_time = floatingView.findViewById(R.id.tv_num); - tv_time.setText("x" + mqttBean.getList().getNumber()); - ToastUtils.show("飘屏创建"); - -// WindowManager windowManager = (WindowManager) mContext.getSystemService(WINDOW_SERVICE); -// windowManager.addView(floatingView, params); -// }else { -// -// } - - - // 先将视图放置在屏幕右侧外部,避免闪现问题 - floatingView.setTranslationX(10000); // 先放到屏幕外 -// 在 FloatingX 配置中或者通过其他方式设置 - FxAppHelper fxAppHelper = FxAppHelper.builder() - .setContext(mContext) - .setLayoutView(floatingView) - .setGravity(FxGravity.RIGHT_OR_TOP) - .setX(0) - .setY(100) - .setScopeType(FxScopeType.SYSTEM_AUTO) - .build(); - - FloatingX.install(fxAppHelper).show(); - ToastUtils.show("飘屏创建2"); - // 首先从右侧滑入到屏幕中央 - floatingView.post(() -> { - // 确保初始位置在屏幕右侧外部 - floatingView.setTranslationX(floatingView.getWidth()); - - // 第一阶段:从右到屏幕右侧边缘(缓慢进入) - ObjectAnimator animator1 = ObjectAnimator.ofFloat(floatingView, "translationX", - floatingView.getWidth(), 0f); - animator1.setDuration(1500); // 延长动画时间到1.5秒 - animator1.setInterpolator(new DecelerateInterpolator(2.0f)); // 更平缓的减速效果 - animator1.start(); - ToastUtils.show("飘屏创建2第一阶段"); - // 第二阶段:延迟1秒后从当前位置向左滑出 - floatingView.postDelayed(() -> { - ObjectAnimator animator2 = ObjectAnimator.ofFloat(floatingView, "translationX", - 0f, -floatingView.getWidth()); - animator2.setDuration(1500); // 延长动画时间到1.5秒 - animator2.setInterpolator(new DecelerateInterpolator(2.0f)); // 更平缓的减速效果 - animator2.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - // 动画结束后移除悬浮窗 - FloatingX.uninstallAll(); - windowManager.removeView(floatingView); - // 处理下一个消息 - processNextMessage(); - } - }); - animator2.start(); - }, 3000); // 停留1秒 - ToastUtils.show("飘屏创建2第er阶段"); - }); - ToastUtils.show("飘屏结束"); - } - - - public void subscribe() { - try { - if (!EventBus.getDefault().isRegistered(this)) { - EventBus.getDefault().register(this); - } - } catch (Exception e) { - // 处理重复注册或其他异常 - LogUtils.e("PiaoPingManager subscribe error: " + e.getMessage()); - } - } - - public void unsubscribe() { - try { - if (EventBus.getDefault().isRegistered(this)) { - EventBus.getDefault().unregister(this); - } - } catch (Exception e) { - // 处理取消注册异常 - LogUtils.e("PiaoPingManager unsubscribe error: " + e.getMessage()); - } - messageQueue.clear(); - isAnimating = false; // 重置动画状态 - XLHmessageQueue.clear(); - XLHisAnimating = false; - } - -// @Subscribe(threadMode = ThreadMode.MAIN) - public void onMessageReceived(MqttBean mqttBean) { - showPiaoPingMessage(mqttBean); - ToastUtils.show("飘屏"); -// FxAppHelper fxAppHelper = FxAppHelper.builder().setContext( context).setLayout(R.layout.item_piaoping).build(); -// FloatingX.install(fxAppHelper).show(); - } - - @Subscribe(threadMode = ThreadMode.MAIN) - public void onEvent(XLHBean event) { - showPiaoPingMessageXlh(event); - } - - private void showPiaoPingMessageXlh(XLHBean event) { - // 创建 FloatingX 配置 - // 添加到队列 - XLHmessageQueue.offer(event); - // 如果当前没有动画正在进行,则开始处理 - if (!XLHisAnimating) { - processNextMessageXlh(); - } - } - - private void processNextMessageXlh() { - if (XLHmessageQueue.isEmpty()) { - XLHisAnimating = false; - return; - } - - XLHisAnimating = true; - XLHBean xlhBean = XLHmessageQueue.poll(); - displayMessageXlh(xlhBean); - } - - @SuppressLint({"MissingInflatedId", "LocalSuppress"}) - private void displayMessageXlh(XLHBean xlhBean) { - // 获取悬浮窗视图并设置内容 - View floatingView = LayoutInflater.from(mContext).inflate(R.layout.item_piaoping_xlh, new FrameLayout(mContext), false); - TextView textView = floatingView.findViewById(R.id.tv_name); - ImageView xlh_image = floatingView.findViewById(R.id.im_xlh); -// if (xlhBean.getFrom_type() == 1){ -// xlh_image.setImageResource(R.mipmap.xlh_jjks); -// }else { -// xlh_image.setImageResource(R.mipmap.xlh_zsks); -// } - - xlh_image.setImageDrawable(xlhBean.getFrom_type() == 1 ? mContext.getResources().getDrawable(R.mipmap.xlh_jjks) : mContext.getResources().getDrawable(R.mipmap.xlh_zsks)); - - textView.setText(xlhBean.getText()); - - // 先将视图放置在屏幕右侧外部,避免闪现问题 - floatingView.setTranslationX(10000); // 先放到屏幕外 - - FxAppHelper fxAppHelper = FxAppHelper.builder() - .setContext(mContext) - .setLayoutView(floatingView) - .setGravity(FxGravity.RIGHT_OR_TOP) - .setX(0) - .setY(100) - .build(); - - FloatingX.install(fxAppHelper).show(); -// 添加点击事件监听器 - floatingView.setOnClickListener(v -> { - // 点击时执行跳转操作 - handleItemClick(xlhBean); - }); - // 首先从右侧滑入到屏幕中央 - floatingView.post(() -> { - // 确保初始位置在屏幕右侧外部 - floatingView.setTranslationX(floatingView.getWidth()); - - // 第一阶段:从右到屏幕右侧边缘(缓慢进入) - ObjectAnimator animator1 = ObjectAnimator.ofFloat(floatingView, "translationX", - floatingView.getWidth(), 0f); - animator1.setDuration(1500); // 延长动画时间到1.5秒 - animator1.setInterpolator(new DecelerateInterpolator(2.0f)); // 更平缓的减速效果 - animator1.start(); - - // 第二阶段:延迟1秒后从当前位置向左滑出 - floatingView.postDelayed(() -> { - ObjectAnimator animator2 = ObjectAnimator.ofFloat(floatingView, "translationX", - 0f, -floatingView.getWidth()); - animator2.setDuration(1500); // 延长动画时间到1.5秒 - animator2.setInterpolator(new DecelerateInterpolator(2.0f)); // 更平缓的减速效果 - animator2.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - // 动画结束后移除悬浮窗 - FloatingX.uninstallAll(); - // 处理下一个消息 - processNextMessageXlh(); - } - }); - animator2.start(); - }, 4000); // 停留1秒 - }); - } - - private void handleItemClick(XLHBean xlhBean) { - // 这里可以根据实际需求实现跳转逻辑 - // 例如:跳转到礼物详情页面、用户主页等 - - ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", xlhBean.getRoom_id()).navigation(); - - } -} - diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/RoomFriendshipWheatView.java b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/RoomFriendshipWheatView.java index cedd0ec..007e30b 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/RoomFriendshipWheatView.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/RoomFriendshipWheatView.java @@ -105,6 +105,7 @@ public class RoomFriendshipWheatView extends BaseWheatView { if (showBoss && WHEAT_BOSS.equals(pitNumber)) { mIvTagBoss.setVisibility(GONE); } + mCharmView.setVisibility(VISIBLE); } else { mTvName.setText((!"10".equals(pitBean.getPit_number()) && !"9".equals(pitBean.getPit_number())) ? pitBean.getPit_number() : ""); //麦位上锁 @@ -129,6 +130,7 @@ public class RoomFriendshipWheatView extends BaseWheatView { //停止声浪 mIvRipple.stopAnimation( true); mIvRipple.setVisibility(GONE); + mCharmView.setVisibility(GONE); } if (showSexIcon) { checkSex(); @@ -256,7 +258,11 @@ public class RoomFriendshipWheatView extends BaseWheatView { final float scale = getContext().getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); } - +// public void setmCharmView(String charm){ +// if (mCharmView!=null){ +// mCharmView.setSex(pitBean.getSex(),pitBean.getUser_id(), charm,false); +// } +// } /** * 开启计时 diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/RoomMakeWheatView.java b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/RoomMakeWheatView.java index 19cd32b..38c687b 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/RoomMakeWheatView.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/RoomMakeWheatView.java @@ -12,6 +12,7 @@ import com.xscm.moduleutil.R; import com.xscm.moduleutil.bean.UserOnlineStatusBean; import com.xscm.moduleutil.bean.room.RoomPitBean; import com.xscm.moduleutil.utils.ImageUtils; +import com.xscm.moduleutil.utils.StringUtil; public class RoomMakeWheatView extends BaseWheatView { @@ -156,7 +157,7 @@ public class RoomMakeWheatView extends BaseWheatView { }else { mTvTime.setVisibility(VISIBLE); } - mTvTime.setText(pitBean.getCharm()); + mTvTime.setText(StringUtil.toWan2(pitBean.getCharm(),1)); }else if (pitBean.getPit_number().equals("000")){ iv_tag_type.setVisibility(GONE); mCharmView.setVisibility(GONE); diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/dialog/RewardGiftDialogFragment.java b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/dialog/RewardGiftDialogFragment.java index 2c7302d..609c800 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/dialog/RewardGiftDialogFragment.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/dialog/RewardGiftDialogFragment.java @@ -8,6 +8,7 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.viewpager.widget.ViewPager; import android.content.Context; import android.os.Bundle; @@ -34,13 +35,17 @@ import com.xscm.moduleutil.color.ThemeableDrawableUtils; import com.xscm.moduleutil.databinding.FragmentRewardGiftDialogBinding; import com.xscm.moduleutil.dialog.RechargeDialogFragment; import com.xscm.moduleutil.event.GiftRewardEvent; +import com.xscm.moduleutil.event.GiftUserRefreshEvent; import com.xscm.moduleutil.presenter.RewardGiftContacts; import com.xscm.moduleutil.presenter.RewardGiftPresenter; import com.xscm.moduleutil.utils.ColorManager; import com.xscm.moduleutil.utils.ImageUtils; import com.xscm.moduleutil.widget.GifAvatarOvalView; +import com.xscm.moduleutil.widget.floatingView.IFloatingView; import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.List; @@ -101,6 +106,9 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment giftLabelBeanList; @Override public void getGiftLabel(List giftLabelBeans) { +// giftLabelBeanList = new ArrayList<>(); +// giftLabelBeanList.addAll(giftLabelBeans); +// GiftLabelBean giftLabelBean = new GiftLabelBean(); +// giftLabelBean.setId("0"); +// giftLabelBean.setName("背包"); +// giftLabelBeans.add(0, giftLabelBean); mBinding.viewPager.setAdapter(new MyFragmentPagerAdapter(getChildFragmentManager(), giftLabelBeans,fragmentList,"")); mBinding.slidingTabLayout.setViewPager(mBinding.viewPager); mBinding.slidingTabLayout.setCurrentTab(0); + refreshCurrentGiftFragment(giftLabelBeans.get(0).getId(),2,""); + mBinding.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + + } + + @Override + public void onPageSelected(int position) { + // 当页面切换时,控制 tv_bb_qs 按钮的显示 + refreshCurrentGiftFragment(giftLabelBeans.get(position).getId(),2,""); + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + }); } + private void refreshCurrentGiftFragment(String id,int type,String roomId) { + if (getCurrentGiftFragment()!=null){ + getCurrentGiftFragment().loadDataIfNeeded(id,type,roomId); + } + } + private GiftTwoDetailsFragment getCurrentGiftFragment() { + int currentPosition = mBinding.viewPager.getCurrentItem(); + // 使用 ViewPager 的 adapter 获取当前 fragment + MyFragmentPagerAdapter adapter = (MyFragmentPagerAdapter) mBinding.viewPager.getAdapter(); + if (adapter != null) { + // 直接从 adapter 获取 fragment + Fragment fragment = adapter.getItem(currentPosition); + if (fragment instanceof GiftTwoDetailsFragment) { + return (GiftTwoDetailsFragment) fragment; + } + } + return null; + } + private GiftPackBean giftModel = null; private int getSelectedGift() { int currentItem = mBinding.viewPager.getCurrentItem(); // if (currentItem < 1) { //比2小是才是礼物 - GiftTwoDetailsFragment fragment = (GiftTwoDetailsFragment) fragmentList.get(currentItem); - roonGiftModel = fragment.getGiftList(); +// GiftTwoDetailsFragment fragment = (GiftTwoDetailsFragment) fragmentList.get(currentItem); +// roonGiftModel = fragment.getGiftList(); // } // else { // GiftFragment fragment = (GiftFragment) fragmentList.get(currentItem); // giftModel = fragment.getmData(); +// } + +// if (currentItem < 1) { //比1小的是背包 +// GiftTwoDetailsFragment fragment = (GiftTwoDetailsFragment) fragmentList.get(currentItem); +// if (fragment != null && giftModel == null) { +// giftModel = fragment.mGiftList(); +// } +// } else { +// GiftTwoDetailsFragment fragment = (GiftTwoDetailsFragment) fragmentList.get(currentItem); +// if (fragment != null && roonGiftModel == null) { +// roonGiftModel = fragment.getGiftList(); +// } // } return currentItem; } + @Subscribe(threadMode = ThreadMode.MAIN) + public void userRefresh(GiftUserRefreshEvent event) { + if (event.addSelf) { + roonGiftModel = event.gift; + } + } private void giveGift(String num) { getSelectedGift(); int currentItem = mBinding.viewPager.getCurrentItem(); String userId = user_id; - if (currentItem < 1) { - if (roonGiftModel == null) { - ToastUtils.show("请选择礼物"); - return; - } - - - if (TextUtils.isEmpty(num)) { - ToastUtils.show("请选择打赏礼物数量"); - return; - } - if (Integer.valueOf(num) <= 0) { - ToastUtils.show("请选择打赏礼物数量"); - return; - } - } else { +// if (currentItem < 1) { +// if (roonGiftModel == null) { +// ToastUtils.show("请选择礼物"); +// return; +// } +// +// +// if (TextUtils.isEmpty(num)) { +// ToastUtils.show("请选择打赏礼物数量"); +// return; +// } +// if (Integer.valueOf(num) <= 0) { +// ToastUtils.show("请选择打赏礼物数量"); +// return; +// } +// } else { if (roonGiftModel == null) { ToastUtils.show("请选择礼物"); return; @@ -242,7 +312,7 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment list; - private List fragmentList ; + private List fragmentList; private String roomId; - public MyFragmentPagerAdapter(FragmentManager fm, List list,List fragmentList,String roomId) { + public MyFragmentPagerAdapter(FragmentManager fm, List list, List fragmentList, String roomId) { super(fm); - this.list = list; - this.fragmentList = fragmentList; + this.list = list != null ? list : new ArrayList<>(); + // 不直接使用传入的 fragmentList,而是创建一个新的列表 + this.fragmentList = new ArrayList<>(); + // 初始化 fragmentList 的大小,用 null 填充 + for (int i = 0; i < this.list.size(); i++) { + this.fragmentList.add(null); + } this.roomId = roomId; } @Override public Fragment getItem(int position) { + // 边界检查 + if (position < 0 || list == null || position >= list.size()) { + return null; + } + + // 检查该位置是否已经有 Fragment 实例 + if (position < fragmentList.size() && fragmentList.get(position) != null) { + return fragmentList.get(position); + } + // 创建新的 Fragment GiftLabelBean model = list.get(position); - Fragment fragment = GiftTwoDetailsFragment.newInstance(model.getId(), 2, roomId); - fragmentList.add(fragment); // 保存 Fragment 实例 + Fragment fragment = GiftTwoDetailsFragment.newInstance(model.getId(), 1, roomId); + // 确保 fragmentList 有足够的空间 + while (fragmentList.size() <= position) { + fragmentList.add(null); + } + + // 在指定位置设置 Fragment 实例 + fragmentList.set(position, fragment); return fragment; } @@ -327,6 +434,9 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment= list.size()) { + return null; + } GiftLabelBean model = list.get(position); return model.getName(); } diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/bg_room_gift.png b/moduleUtil/src/main/res/drawable-xxxhdpi/bg_room_gift.png deleted file mode 100644 index 632aa7d..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/bg_room_gift.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/bg_room_gift.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/bg_room_gift.webp new file mode 100644 index 0000000..3adf297 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/bg_room_gift.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/detail_icon_go.png b/moduleUtil/src/main/res/drawable-xxxhdpi/detail_icon_go.png deleted file mode 100644 index 1bd70dd..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/detail_icon_go.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/detail_icon_go.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/detail_icon_go.webp new file mode 100644 index 0000000..a1139bb Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/detail_icon_go.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/group.png b/moduleUtil/src/main/res/drawable-xxxhdpi/group.png deleted file mode 100644 index eb24fc2..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/group.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/group.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/group.webp new file mode 100644 index 0000000..50bb34d Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/group.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_selected.png b/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_selected.png deleted file mode 100644 index 38f965c..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_selected.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_selected.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_selected.webp new file mode 100644 index 0000000..2080b80 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_selected.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_unselect.png b/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_unselect.png deleted file mode 100644 index 304a7b4..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_unselect.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_unselect.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_unselect.webp new file mode 100644 index 0000000..971318a Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/ic_agreement_unselect.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_0.png b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_0.png deleted file mode 100644 index 08d5a37..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_0.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_0.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_0.webp new file mode 100644 index 0000000..236dd39 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_0.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_1.png b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_1.png deleted file mode 100644 index ff33167..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_1.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_1.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_1.webp new file mode 100644 index 0000000..a9318d8 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_btn_radio_1.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_select.png b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_select.png deleted file mode 100644 index 38f965c..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_select.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_select.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_select.webp new file mode 100644 index 0000000..2080b80 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_select.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_unselect.png b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_unselect.png deleted file mode 100644 index 304a7b4..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_unselect.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_unselect.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_unselect.webp new file mode 100644 index 0000000..971318a Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/icon_pay_unselect.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/img_emperor.png b/moduleUtil/src/main/res/drawable-xxxhdpi/img_emperor.png deleted file mode 100644 index 5d0ebe7..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/img_emperor.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/img_emperor.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/img_emperor.webp new file mode 100644 index 0000000..e7d0b1c Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/img_emperor.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/me_avatar_bg.png b/moduleUtil/src/main/res/drawable-xxxhdpi/me_avatar_bg.png deleted file mode 100644 index 8d7530c..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/me_avatar_bg.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/me_avatar_bg.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/me_avatar_bg.webp new file mode 100644 index 0000000..8ed29c1 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/me_avatar_bg.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_normal.png b/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_normal.png deleted file mode 100644 index 2058f38..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_normal.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_normal.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_normal.webp new file mode 100644 index 0000000..3687545 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_normal.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_selected.png b/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_selected.png deleted file mode 100644 index 7191a19..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_selected.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_selected.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_selected.webp new file mode 100644 index 0000000..65d03df Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/meinfo_skill_star_selected.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/phonetic.png b/moduleUtil/src/main/res/drawable-xxxhdpi/phonetic.png deleted file mode 100644 index 73fafe2..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/phonetic.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/phonetic.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/phonetic.webp new file mode 100644 index 0000000..6a279de Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/phonetic.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00000.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00000.png deleted file mode 100644 index 5101bd9..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00000.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00000.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00000.webp new file mode 100644 index 0000000..4088c10 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00000.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00001.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00001.png deleted file mode 100644 index 9cc043e..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00001.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00001.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00001.webp new file mode 100644 index 0000000..aa3bde0 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00001.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00002.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00002.png deleted file mode 100644 index 0f70eb7..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00002.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00002.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00002.webp new file mode 100644 index 0000000..56bdcc9 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00002.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00003.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00003.png deleted file mode 100644 index a82d333..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00003.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00003.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00003.webp new file mode 100644 index 0000000..cb880fe Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00003.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00004.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00004.png deleted file mode 100644 index 9abd312..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00004.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00004.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00004.webp new file mode 100644 index 0000000..ab5c1d8 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00004.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00005.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00005.png deleted file mode 100644 index 5783a47..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00005.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00005.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00005.webp new file mode 100644 index 0000000..55b807a Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00005.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00006.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00006.png deleted file mode 100644 index bffae5c..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00006.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00006.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00006.webp new file mode 100644 index 0000000..dc4e840 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00006.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00007.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00007.png deleted file mode 100644 index 347f398..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00007.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00007.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00007.webp new file mode 100644 index 0000000..c72edb3 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00007.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00008.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00008.png deleted file mode 100644 index 29389ea..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00008.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00008.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00008.webp new file mode 100644 index 0000000..409e1d1 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00008.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00009.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00009.png deleted file mode 100644 index 3e36aab..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00009.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00009.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00009.webp new file mode 100644 index 0000000..a7a94fa Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00009.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00010.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00010.png deleted file mode 100644 index be53fb1..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00010.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00010.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00010.webp new file mode 100644 index 0000000..d3d05d4 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00010.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00011.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00011.png deleted file mode 100644 index 7035d6d..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00011.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00011.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00011.webp new file mode 100644 index 0000000..feb5213 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00011.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00012.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00012.png deleted file mode 100644 index 7e68f0d..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00012.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00012.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00012.webp new file mode 100644 index 0000000..270a972 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00012.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00013.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00013.png deleted file mode 100644 index 97fd399..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00013.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00013.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00013.webp new file mode 100644 index 0000000..1f933aa Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00013.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00014.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00014.png deleted file mode 100644 index feb2a80..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00014.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00014.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00014.webp new file mode 100644 index 0000000..9049182 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00014.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00015.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00015.png deleted file mode 100644 index 4957395..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00015.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00015.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00015.webp new file mode 100644 index 0000000..3f6d9ac Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00015.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00016.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00016.png deleted file mode 100644 index 3a3c964..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00016.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00016.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00016.webp new file mode 100644 index 0000000..aea576d Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00016.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00017.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00017.png deleted file mode 100644 index 933505f..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00017.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00017.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00017.webp new file mode 100644 index 0000000..9c34b78 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00017.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00018.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00018.png deleted file mode 100644 index b5f884a..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00018.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00018.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00018.webp new file mode 100644 index 0000000..86c96e3 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00018.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00019.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00019.png deleted file mode 100644 index 8774e4d..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00019.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00019.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00019.webp new file mode 100644 index 0000000..d7c94f6 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00019.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00020.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00020.png deleted file mode 100644 index cb0adc4..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00020.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00020.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00020.webp new file mode 100644 index 0000000..8a65110 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00020.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00021.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00021.png deleted file mode 100644 index 08882a8..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00021.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00021.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00021.webp new file mode 100644 index 0000000..f968efb Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00021.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00022.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00022.png deleted file mode 100644 index cb757e1..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00022.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00022.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00022.webp new file mode 100644 index 0000000..8c25a86 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00022.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00023.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00023.png deleted file mode 100644 index 7868a8c..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00023.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00023.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00023.webp new file mode 100644 index 0000000..63cb1fd Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00023.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00024.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00024.png deleted file mode 100644 index c6b698e..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00024.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00024.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00024.webp new file mode 100644 index 0000000..54a777f Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00024.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00025.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00025.png deleted file mode 100644 index 14dc2d4..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00025.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00025.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00025.webp new file mode 100644 index 0000000..7840457 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00025.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00026.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00026.png deleted file mode 100644 index 5c7966f..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00026.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00026.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00026.webp new file mode 100644 index 0000000..0fd1c00 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00026.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00027.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00027.png deleted file mode 100644 index 97f9130..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00027.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00027.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00027.webp new file mode 100644 index 0000000..da9a70a Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00027.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00028.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00028.png deleted file mode 100644 index 7ff50e4..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00028.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00028.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00028.webp new file mode 100644 index 0000000..b693146 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00028.webp differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00029.png b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00029.png deleted file mode 100644 index f1ceeec..0000000 Binary files a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00029.png and /dev/null differ diff --git a/moduleUtil/src/main/res/drawable-xxxhdpi/star_00029.webp b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00029.webp new file mode 100644 index 0000000..c472849 Binary files /dev/null and b/moduleUtil/src/main/res/drawable-xxxhdpi/star_00029.webp differ diff --git a/moduleUtil/src/main/res/layout/dialog_confirm.xml b/moduleUtil/src/main/res/layout/dialog_confirm.xml index 5ea0491..aff015d 100644 --- a/moduleUtil/src/main/res/layout/dialog_confirm.xml +++ b/moduleUtil/src/main/res/layout/dialog_confirm.xml @@ -52,12 +52,11 @@ android:layout_centerInParent="true" android:layout_alignParentStart="true" android:layout_marginStart="@dimen/dp_20" - android:layout_gravity="left" android:text="取消" android:textSize="@dimen/sp_14" android:textColor="@color/color_FF999999" - android:layout_marginEnd="16dp" android:background="@drawable/bg_r53_f3f3f3" + />