优化麦圈,泄漏处理

This commit is contained in:
2025-12-24 18:33:06 +08:00
parent 342cfd347c
commit 84fb05044a
11 changed files with 168 additions and 197 deletions

View File

@@ -256,13 +256,14 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
@Override
public void finish() {
EventBus.getDefault().unregister(this);
super.finish();
LogUtils.e(this.getComponentName()+"========finish");
}
@Override
protected void onDestroy() {
EventBus.getDefault().unregister(this);
// 移除背景更新监听器
BackgroundManager.getInstance().removeListener(this);
// 移除颜色变化监听器

View File

@@ -18,6 +18,7 @@ import android.content.Context;
import android.media.projection.MediaProjection;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
@@ -54,7 +55,9 @@ import java.io.FileInputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -120,6 +123,14 @@ public class AgoraManager {
private Disposable disposableB;
private Disposable disposableC;
// UI 刷新最小间隔ms
private static final long SOUND_UI_INTERVAL = 200;
private final Handler uiHandler = new Handler(Looper.getMainLooper());
private long lastDispatchTime = 0;
// 缓存本次声网回调的音量结果
private final Map<String, Integer> volumeCache = new HashMap<>();
public void setLastRoomId(String value) {
lastRoomId = value;
}
@@ -549,22 +560,33 @@ public class AgoraManager {
if (speakers == null || speakers.length == 0) return;
for (final AudioVolumeInfo info : speakers) {
final int uid = info.uid;
final int volume = info.volume;
// 1⃣ 构建局部 Map声网线程私有
Map<String, Integer> localMap = new HashMap<>();
for (AudioVolumeInfo info : speakers) {
String userId = info.uid > 0
? String.valueOf(info.uid)
: String.valueOf(SpUtil.getUserId());
localMap.put(userId, info.volume);
}
// 回调所有监听器
long now = SystemClock.uptimeMillis();
if (now - lastDispatchTime < SOUND_UI_INTERVAL) return;
lastDispatchTime = now;
// 2⃣ 只把“不可变快照”丢给 UI
uiHandler.post(() -> dispatchVolume(localMap));
}
private void dispatchVolume(Map<String, Integer> volumeSnapshot) {
if (soundLevelUpdateListeners.isEmpty()) return;
for (Map.Entry<String, Integer> entry : volumeSnapshot.entrySet()) {
for (SoundLevelUpdateListener listener : soundLevelUpdateListeners) {
if (listener != null) {
ThreadUtils.runOnUiThread(() -> {
// 远程用户音量变化
listener.onRemoteSoundLevelUpdate(uid > 0 ? String.valueOf(uid) : SpUtil.getUserId() + "", volume);
});
listener.onRemoteSoundLevelUpdate(entry.getKey(), entry.getValue());
}
}
}
}
@Override
public void onLocalVideoStateChanged(Constants.VideoSourceType source, int state, int reason) {
super.onLocalVideoStateChanged(source, state, reason);

View File

@@ -262,99 +262,16 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
AgoraManager.getInstance().addSoundLevelListener(new SoundLevelUpdateListener() {
@Override
public void onRemoteSoundLevelUpdate(String userId, int soundLevel) {
if (mIvRipple == null)
return;
if (mIvRipple == null) return;
if (!userId.equals(pitBean.getUser_id())) return;
if (userId.equals(pitBean.getUser_id())) {
if (soundLevel == 0) {
mIvRipple.pauseAnimation();
CommonAppContext.getInstance().onlineMap.put(pitBean.getUser_id(), 1);
mIvRipple.setVisibility(INVISIBLE);
} else {
mIvRipple.setVisibility(VISIBLE);
mIvRipple.post(() -> {
if (!mIvRipple.isAnimating()) {
if (pitBean.getMic_cycle() != null && !pitBean.getMic_cycle().isEmpty()) {
if (mParser != null) {
mIvRipple.startAnimation();
} else {
mParser = new SVGAParser(getContext());
try {
mParser.decodeFromURL(new URL(pitBean.getMic_cycle()), new SVGAParser.ParseCompletion() {
@Override
public void onError() {
}
@Override
public void onComplete(@NotNull SVGAVideoEntity svgaVideoEntity) {
if (mIvRipple == null)
return;
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity);
mIvRipple.setImageDrawable(drawable);
mIvRipple.startAnimation();
}
});
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
} else {
mIvRipple.startAnimation();
}
CommonAppContext.getInstance().onlineMap.put(pitBean.getUser_id(), 1);
iv_on_line.setVisibility(GONE);
}
});
}
}
boolean nowSpeaking = soundLevel > 0;
updateSpeakingState(nowSpeaking);
}
@Override
public void onLocalSoundLevelUpdate(int volume) {
if (mIvRipple == null)
return;
if (volume == 0) {
mIvRipple.setVisibility(GONE);
} else {
mIvRipple.setVisibility(VISIBLE);
if (!mIvRipple.isAnimating()) {
if (pitBean.getMic_cycle()!=null && !pitBean.getMic_cycle().isEmpty()) {
if (mParser != null) {
mIvRipple.startAnimation();
} else {
mParser = new SVGAParser(getContext());
try {
mParser.decodeFromURL(new URL(pitBean.getMic_cycle()), new SVGAParser.ParseCompletion() {
@Override
public void onError() {
}
@Override
public void onComplete(@NotNull SVGAVideoEntity svgaVideoEntity) {
if (mIvRipple == null)
return;
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity);
mIvRipple.setImageDrawable(drawable);
mIvRipple.startAnimation();
}
});
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}else {
mIvRipple.startAnimation();
}
CommonAppContext.getInstance().onlineMap.put(pitBean.getUser_id(), 1);
iv_on_line.setVisibility(GONE);
}
}
}
@Override
@@ -379,6 +296,59 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
}
private boolean isSpeaking = false;
private void updateSpeakingState(boolean nowSpeaking) {
// 1⃣ 状态未变化,直接丢弃(核心)
if (nowSpeaking == isSpeaking) return;
isSpeaking = nowSpeaking;
if (!nowSpeaking) {
// 静音状态
mIvRipple.pauseAnimation();
mIvRipple.setVisibility(INVISIBLE);
return;
}
// 2⃣ 开始说话(只触发一次)
mIvRipple.setVisibility(VISIBLE);
iv_on_line.setVisibility(GONE);
CommonAppContext.getInstance().onlineMap.put(pitBean.getUser_id(), 1);
if (!mIvRipple.isAnimating()) {
startRippleAnimation();
}
}
private void startRippleAnimation() {
if (mParser != null) {
mIvRipple.startAnimation();
return;
}
if (pitBean.getMic_cycle() == null || pitBean.getMic_cycle().isEmpty()) {
mIvRipple.startAnimation();
return;
}
try {
mParser = new SVGAParser(getContext());
mParser.decodeFromURL(new URL(pitBean.getMic_cycle()),
new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NotNull SVGAVideoEntity svgaVideoEntity) {
if (mIvRipple == null) return;
mIvRipple.setImageDrawable(new SVGADrawable(svgaVideoEntity));
mIvRipple.startAnimation();
}
@Override
public void onError() {}
});
} catch (MalformedURLException ignored) {}
}
public void setCharm(String charm) {
mCharmView.setSex(pitBean.getSex(), pitBean.getUser_id(), charm, false);
}

View File

@@ -70,7 +70,5 @@ dependencies {
api project(':tuichat')
api project(':BaseModule')
api project(':appupdate')
}
apply plugin: 'com.alibaba.arouter' //

View File

@@ -58,7 +58,8 @@
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustPan" />
android:windowSoftInputMode="adjustPan"
android:persistableMode="persistAcrossReboots"/><!-- 防止系统回收 View 层级Android 11+ -->
<activity
android:name=".activity.room.activity.RedResultActivity"
android:exported="true" />

View File

@@ -29,6 +29,7 @@ import com.xscm.moduleutil.utils.CustomMsgCode
import io.reactivex.disposables.Disposable
import org.json.JSONObject
import java.io.File
import java.lang.ref.WeakReference
import java.util.concurrent.TimeUnit
@@ -41,9 +42,20 @@ open class Application : CommonAppContext() {
var isAgoraStop = false
var inviteDialog: InviteDialog? = null
var currDialogActivity: Activity? = null
// 改为弱引用持有Activity
private var mCurDialogActivityRef: WeakReference<Activity>? = null
fun setCurDialogActivity(activity: Activity?) {
mCurDialogActivityRef = WeakReference(activity)
}
fun getCurDialogActivity(): Activity? {
if (mCurDialogActivityRef != null) {
return mCurDialogActivityRef!!.get()
}
return null
}
@@ -77,6 +89,10 @@ open class Application : CommonAppContext() {
// 初始化单例实例
instance = this
configureLeakCanary()
// 初始化并预绘制视图 二卡八列
WheatLayoutSingManager.init(this)
WheatLayoutSingManager.getInstance().setWheatData(null)
@@ -91,6 +107,15 @@ open class Application : CommonAppContext() {
initImMsg()
}
/**
* 自定义 LeakCanary 配置(解决误报、优化检测规则)
*/
private fun configureLeakCanary() {
// LeakCanary.config = LeakCanary.config.copy(
// retainedVisibleThreshold = 3, // 对象被观察几次GC未被回收才认为泄漏 (默认5)
// )
}
private fun initImMsg() {
MessageListenerSingleton.getInstance().setOnMsgTaskListener { event ->
when (event.msgType) {
@@ -240,7 +265,7 @@ open class Application : CommonAppContext() {
fun showInviteDialog(activity: Activity?, t: IndexRecommendRoom) {
if (isKeepScreenOn)
return
if (activity != null && activity == currDialogActivity && inviteDialog != null) {
if (activity != null && activity == getCurDialogActivity() && inviteDialog != null) {
inviteDialog?.setData(t)
return
}
@@ -249,7 +274,7 @@ open class Application : CommonAppContext() {
inviteDialog = activity?.let { InviteDialog(it, t) }
inviteDialog?.setData(t)
currDialogActivity = activity
setCurDialogActivity(activity)
}
private fun initLogUtils() {

View File

@@ -168,6 +168,7 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
@Override
protected void onDestroy() {
ClickUtils.clearAllClickRecords();
// 清理MQTT相关资源
synchronized (mqttQueueLock) {
mqttMessageQueue.clear();

View File

@@ -35,6 +35,7 @@ import com.alibaba.android.arouter.facade.annotation.Route;
import com.azhon.appupdate.listener.OnButtonClickListener;
import com.azhon.appupdate.listener.OnDownloadListener;
import com.azhon.appupdate.manager.DownloadManager;
import com.azhon.appupdate.util.ApkUtil;
import com.blankj.utilcode.util.FragmentUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
@@ -47,6 +48,7 @@ import com.tencent.imsdk.v2.V2TIMValueCallback;
import com.xscm.modulemain.Application;
import com.xscm.modulemain.BaseMvpActivity;
import com.xscm.modulemain.R;
import com.xscm.modulemain.TransparentActivity;
import com.xscm.modulemain.activity.main.contacts.HomeContacts;
import com.xscm.modulemain.activity.main.presenter.HomePresenter;
import com.xscm.modulemain.activity.msg.fragment.NewsFragment;
@@ -142,7 +144,7 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
}
}
// toActivity(TransparentActivity.class);
// 处理新的intent
// setIntent(intent);
// 处理tab切换
@@ -150,6 +152,12 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
LogUtils.e("MainActivity", "onWindowFocusChanged:"+hasFocus);
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -184,6 +192,8 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
MessageListenerSingleton.getInstance().ensureListenersAdded();
CommonAppContext.getInstance().upMqtt();
Application.Companion.getInstance().bgToForeground();
//delete downloaded old Apk
ApkUtil.Companion.deleteOldApk(this,getExternalCacheDir().getAbsolutePath() + "/yusheng.apk");
}
@Override

View File

@@ -178,10 +178,7 @@ import com.xscm.moduleutil.widget.ViewUtils
import com.xscm.moduleutil.widget.ViewUtils.OnViewCreatedListener
import com.xscm.moduleutil.widget.floatingView.Floa
import io.agora.musiccontentcenter.Music
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
@@ -192,7 +189,6 @@ import java.lang.ref.WeakReference
import java.nio.charset.StandardCharsets
import java.util.Arrays
import java.util.Date
import java.util.concurrent.TimeUnit
import java.util.stream.Collectors
@Route(path = ARouteConstants.ROOM_DETAILS)
@@ -235,10 +231,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
private var circularProgress: CircularProgressView? = null
private var publicScreenFragment: ChatRoomFragment? = null // 添加成员变量
// 存储当前显示的弹框引用
private val activeDialogs: MutableList<DialogInterface> = ArrayList()
private val activeDialogFragments: MutableList<Fragment> = ArrayList()
private var isMinimized = false
private var appStateListener: AppStateListener? = null
@@ -289,16 +281,20 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
taskId = intent.getStringExtra("taskId")
mRoomInfoResp = roomInfoResp
}
setView(mRoomInfoResp)
toActivity(TransparentActivity::class.java)
LogUtils.e("RoomActivity", "onNewIntent")
}
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
LogUtils.e("RoomActivity", "onWindowFocusChanged:${hasFocus}")
}
override fun onCreate(savedInstanceState: Bundle?) {
// 在super.onCreate之前设置主题以避免闪白屏
// setTheme(com.xscm.moduleutil.R.style.BaseAppTheme) // 设置你的主主题
super.onCreate(savedInstanceState)
// // 进入房间10s后检查是否显示提示上麦对话框
LogUtils.e("RoomActivity", "onCreate")
isSave = false
sDestroied = false
@@ -606,16 +602,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
MvpPre?.getRoomOnline(roomId, "1", "10")
}
// 添加弹框到管理列表
fun addActiveDialog(dialog: DialogInterface) {
activeDialogs.add(dialog)
}
fun addActiveDialogFragment(dialogFragment: Fragment) {
activeDialogFragments.add(dialogFragment)
}
private var bgEffectView: View? = null
private fun setupEffectView() {
@@ -831,7 +817,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
}
})
bottomSheet.show(supportFragmentManager, "ExitRoomBottomSheet")
addActiveDialogFragment(bottomSheet)
}
override fun onConfigurationChanged(newConfig: Configuration) {
@@ -906,21 +891,33 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
override fun onSelfInfoUpdated(info: V2TIMUserFullInfo?) {}
}
/**
* Sets up the room view with the provided room information response.
*
* @param resp The room information response object containing room details
* @param isSwitchRoomType Flag indicating if room type is being switched (default: false)
*/
@SuppressLint("CheckResult")
private fun setView(resp: RoomInfoResp?, isSwitchRoomType: Boolean = false) {
// Return early if response is null
if (resp == null)
return
// Update room info in app state manager and local instance
AppStateManager.getInstance().roomInfo = resp
this.mRoomInfoResp = resp
val roomBean = resp.room_info
// Log room info for debugging
LogUtils.e("setView_mRoomBean", resp.toString())
// Set user and owner information
this.mRoomUserBean = resp.user_info
this.mRoomOwnerBean = resp.room_owner
this.roomId = roomBean.room_id
// Load room cover image and set room details
ImageUtils.loadHeadCC(resp.room_info.room_cover, mBinding!!.roomTop.avatar)
mBinding!!.roomTop.name.text = roomBean.room_name
mBinding!!.roomTop.idVal.text = "ID:" + roomBean.room_number
// Handle follow button visibility based on user role
if (mRoomUserBean?.getIs_room_owner() == 1) {
mBinding!!.roomTop.btnFollow.visibility = View.GONE
} else {
@@ -931,15 +928,19 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
mBinding!!.roomTop.btnFollow.text = ""
}
}
// Set online number display
number = roomBean.online_number
mBinding!!.roomTop.tvNum.text = number.toString() + ""
// Set initial view if not switching room type
if (!isSwitchRoomType) {
setviewyc(true)
}
// Log room join action
LogUtils.e("加入", roomId)
// Build comma-separated user IDs from pit list
val userIds = StringBuilder()
if (mRoomInfoResp?.room_info?.pit_list != null) {
for (i in mRoomInfoResp?.room_info?.pit_list!!.indices) {
@@ -952,6 +953,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
}
}
}
// Update app context with room information
CommonAppContext.getInstance().isPlaying = true
CommonAppContext.getInstance().playId = roomId
CommonAppContext.getInstance().playName = mRoomInfoResp?.room_info?.room_name
@@ -959,6 +961,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
CommonAppContext.getInstance().playCover = resp.room_info.room_cover
CommonAppContext.getInstance().showSelf = resp.is_show_self == 1
// Update follow button appearance based on collection status
if (mRoomUserBean?.getIs_collect() == 1) {
mBinding!!.roomTop.btnFollow.background =
resources.getDrawable(com.xscm.moduleutil.R.mipmap.yishouc)
@@ -972,19 +975,23 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
mBinding!!.roomTop.btnFollow.setTextColor(ColorManager.getInstance().buttonColorInt)
mBinding!!.roomTop.btnFollow.text = "收藏"
}
// Set music type based on room type
if ((roomBean.type_id == "3" || roomBean.type_id == "1" || roomBean.type_id == "4") && roomBean.label_id == "2") {
AgoraManager.getInstance().isBjMusic = false
} else {
AgoraManager.getInstance().isBjMusic = true
}
// Update user permissions
userPermissionChange()
// Hide PK and misc views for specific room types
if (resp.room_info.type_id == "7" || resp.room_info.type_id == "2") {
mBinding!!.rlPk.visibility = View.GONE
mBinding!!.rlMisc.visibility = View.GONE
}
// Handle lucky draw countdown visibility
if (mRoomInfoResp?.gift_cycle?.xlh_info?.xlh_status == "1") {
mBinding?.xlhRk?.visibility = View.VISIBLE
xlhDjs(mRoomInfoResp?.gift_cycle?.xlh_info?.end_time)
@@ -993,6 +1000,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
releaseCountDownTimer1()
}
// Show/hide hourly ranking based on settings
if (mRoomInfoResp?.hour_ranking_open == 1) {
mBinding!!.clXsb.visibility = View.VISIBLE
} else {
@@ -1098,9 +1106,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
roomId, null,
supportFragmentManager, "", ""
)
if (fragment != null) {
addActiveDialogFragment(fragment) // 添加到管理列表
}
}, 1400)
}
hideGiftGiveProgress()
@@ -1133,9 +1138,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
roomId, null,
supportFragmentManager, "", ""
)
if (fragment != null) {
addActiveDialogFragment(fragment) // 添加到管理列表
}
}, 1400)
}
hideGiftGiveProgress()
@@ -2258,6 +2260,10 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
val pitArr: MutableList<RoomPitBean> = ArrayList()
for (j in text.list.indices) {
val roomPitBean = getRoomPitBean(messageEvent, j)
if(roomPitBean.user_id.equals(mRoomInfoResp?.user_info?.user_id.toString())){
mRoomInfoResp?.user_info?.pit_number = roomPitBean.pit_number.toInt()
roomBtnShowIsHide(mRoomInfoResp?.user_info?.user_id!!)
}
pitArr.add(roomPitBean)
}
@@ -2458,7 +2464,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
}, true, 10
)
dialog.show()
addActiveDialog(dialog)
}
/**
@@ -2521,11 +2526,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
roomNoticeDialogFragment.setTitle("公告")
roomNoticeDialogFragment.setContent(mRoomInfoResp?.room_info?.room_intro)
roomNoticeDialogFragment.show()
addActiveDialog(roomNoticeDialogFragment)
} else if (id == R.id.btn_ranking) { //排行榜
val fragment = RoomChartsFragment.newInstance(roomId, mRoomInfoResp)
fragment.show(supportFragmentManager, "RoomChartsFragment")
addActiveDialogFragment(fragment)
} else if (id == R.id.btn_close_live) { //退出房间
showExitRoomDialog()
} else if (id == R.id.tv_num) {
@@ -2572,9 +2575,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
mRoomInfoResp,
supportFragmentManager
)
if (fragment != null) {
addActiveDialogFragment(fragment) // 添加到管理列表
}
} else if (id == R.id.rl_voive) {
voive = !voive
if (voive) {
@@ -2597,39 +2597,26 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
LogUtils.e("pk_info", "id == R.id.rl_pk ${mRoomInfoResp?.room_info?.is_pk!!}")
fragment.show(supportFragmentManager, "RoomPkDialogFragment")
addActiveDialogFragment(fragment) // 添加到管理列表
} else if (id == R.id.rl_message) {
val fragment = RoomMessageDialogFragment.show(
supportFragmentManager
)
if (fragment != null) {
addActiveDialogFragment(fragment) // 添加到管理列表
}
} else if (id == R.id.rl_misc) { //设置点歌
val fragment = RequestDialogFragment.show(
roomId, mRoomInfoResp, 1,
supportFragmentManager
)
if (fragment != null) {
addActiveDialogFragment(fragment) // 添加到管理列表
}
} else if (id == R.id.rl_gift) { //礼物
LogUtils.e("RoomGiftDialogFragment_RoomActivity");
val fragment = RoomGiftDialogFragment.show(
mRoomInfoResp, null, roomId, 0, "",
supportFragmentManager
)
if (fragment != null) {
addActiveDialogFragment(fragment) // 添加到管理列表
}
} else if (id == R.id.iv_sound_effects) {
val fragment = SoundEffectsDialogFragment.show(
roomId,
supportFragmentManager
)
if (fragment != null) {
addActiveDialogFragment(fragment) // 添加到管理列表
}
} else if (id == R.id.cl_first_charge) {
roomFragment!!.showWheatFeedingDialog(
roomId,
@@ -2776,7 +2763,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
{ v: View? -> }, false, 0
)
dialog.show()
addActiveDialog(dialog)
}
/**
@@ -3033,9 +3019,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
roomId,
supportFragmentManager
)
if (fragment != null) {
addActiveDialogFragment(fragment) // 添加到管理列表
}
}
mBinding!!.ivQuanC.setOnClickListener { v: View? ->
if (mRoomInfoResp?.room_info?.head_line?.room_id != null && mRoomInfoResp?.room_info?.head_line?.room_id!!.isNotEmpty()) {
@@ -3157,7 +3140,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
override fun showPasswordDialog() {
val roomPasswordSetDialogFragment = RoomPasswordSetDialogFragment.newInstance(true, roomId)
roomPasswordSetDialogFragment.show(supportFragmentManager)
addActiveDialogFragment(roomPasswordSetDialogFragment)
}
override fun enterFail() {
@@ -3195,9 +3177,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
roomId, mRoomInfoResp, 2,
supportFragmentManager
)
if (fragment != null) {
addActiveDialogFragment(fragment) // 添加到管理列表
}
}
is RoomInputHideEvent -> {
@@ -3518,11 +3497,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
roomId, pitNumber, mOnlineBean, mRoomUserBean, mRoomInfoResp,
supportFragmentManager
)
LogUtils.e("fragment_onItemClickListener: ${(fragment != null)}")
if (fragment != null) {
addActiveDialogFragment(fragment) // 添加到管理列表
}
}
override fun applyPit() {
@@ -3850,8 +3825,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
// if (AgoraManager.getInstance() != null) {
// AgoraManager.getInstance().cleanup();
// }
// 清理所有弹框
dismissAllDialogs()
// 7. 清理 Fragment
cleanupFragments()
@@ -3897,34 +3870,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
newParent.addView(view)
}
// 清理所有弹框
private fun dismissAllDialogs() {
// 关闭 AlertDialog 实例
for (dialog in activeDialogs) {
if (dialog != null) {
try {
dialog.dismiss()
} catch (e: Exception) {
LogUtils.e("dismiss dialog error: " + e.message)
}
}
}
activeDialogs.clear()
// 移除 DialogFragment
for (fragment in activeDialogFragments) {
if (fragment != null && fragment.isAdded) {
try {
if (fragment is DialogFragment) {
fragment.dismissAllowingStateLoss()
}
} catch (e: Exception) {
LogUtils.e("dismiss dialog fragment error: " + e.message)
}
}
}
activeDialogFragments.clear()
}
private fun clearSVGAResources() {
try {
@@ -4319,8 +4264,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
LogUtils.e("AlertDialog已关闭")
}
dialog.show()
addActiveDialog(dialog) // 添加到管理列表
}
fun dialogMessage(event: RoomInputEvent) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -28,8 +28,8 @@ isBuildModule=false
#org.gradle.deamon=false
android.injected.testOnly=false
APP_VERSION_NAME=1.0.9.0
APP_VERSION_CODE=80
APP_VERSION_NAME=1.0.9.1
APP_VERSION_CODE=81
org.gradle.jvm.toolchain.useLegacyAdapters=false
#org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15