合并2
This commit is contained in:
@@ -20,19 +20,25 @@ import android.text.Spannable
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.TextUtils
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.Log
|
||||
import android.view.GestureDetector
|
||||
import android.view.Gravity
|
||||
import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.view.animation.TranslateAnimation
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
@@ -53,6 +59,7 @@ import com.liulishuo.okdownload.OkDownloadProvider
|
||||
import com.orhanobut.logger.Logger
|
||||
import com.petterp.floatingx.assist.helper.FxScopeHelper
|
||||
import com.petterp.floatingx.listener.control.IFxControl
|
||||
import com.sunfusheng.marqueeview.DisplayUtil
|
||||
import com.tencent.imsdk.v2.V2TIMManager
|
||||
import com.tencent.imsdk.v2.V2TIMSDKListener
|
||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo
|
||||
@@ -432,11 +439,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
override fun initData() {
|
||||
if (!EasyPermissions.hasPermissions(this, *permissions)) {
|
||||
PermissionDescriptionHelper.addPermissionDescription(
|
||||
false,
|
||||
mBinding?.root as ViewGroup,
|
||||
permissions
|
||||
)
|
||||
PermissionDescriptionHelper.addPermissionDescription(false, mBinding?.root as ViewGroup, permissions)
|
||||
EasyPermissions.requestPermissions(
|
||||
this, "请开启录音使用权限",
|
||||
1, *permissions
|
||||
@@ -492,7 +495,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
this, LinearLayoutManager.HORIZONTAL, false
|
||||
)
|
||||
likeUserAdapter = LikeUserAdapter()
|
||||
mBinding!!.roomTop.userRecyclerView.adapter = likeUserAdapter
|
||||
mBinding?.roomTop?.userRecyclerView?.adapter = likeUserAdapter
|
||||
likeUserAdapter!!.onItemClickListener =
|
||||
BaseQuickAdapter.OnItemClickListener { adapter, view, position ->
|
||||
// RoomOnlineDialogFragment.show(roomId, "", mRoomUserBean, mRoomInfoResp, getSupportFragmentManager());
|
||||
@@ -690,14 +693,22 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置顶部操作按钮的可见性和点击事件
|
||||
* 包括结束按钮和延时按钮的初始化和事件绑定
|
||||
*/
|
||||
fun tob() {
|
||||
// 获取并显示stubButtons2布局
|
||||
val stub = mBinding!!.roomTop.stubButtons2
|
||||
stub.visibility = View.VISIBLE
|
||||
// 获取结束按钮和延时按钮的ImageView控件
|
||||
val imActionJs = mBinding!!.roomTop.imActionJs.findViewById<ImageView>(R.id.im_action_js)
|
||||
val imActionYs = mBinding!!.roomTop.imActionYs.findViewById<ImageView>(R.id.im_action_ys)
|
||||
if (imActionJs != null && imActionYs != null) {
|
||||
imActionJs.setOnClickListener { dialogEnd() }
|
||||
// 设置结束按钮点击事件,调用dialogEnd()方法
|
||||
imActionYs.setOnClickListener {
|
||||
// 设置延时按钮点击事件,调用MvpPre的auctionDelay方法,传入当前拍卖ID
|
||||
MvpPre!!.auctionDelay(
|
||||
SpUtil.getauctionId()
|
||||
)
|
||||
@@ -744,6 +755,8 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
if (visible) View.VISIBLE else View.INVISIBLE
|
||||
}
|
||||
|
||||
// 根据传入的visible参数设置JS按钮的可见性
|
||||
// 使用View.VISIBLE显示按钮,使用View.INVISIBLE隐藏按钮
|
||||
fun upYs(visible: Boolean) {
|
||||
mBinding!!.roomTop.imActionYs.visibility =
|
||||
if (visible) View.VISIBLE else View.INVISIBLE
|
||||
@@ -820,7 +833,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
* 释放当前房间
|
||||
*/
|
||||
private fun releaseRoom() {
|
||||
AgoraManager.getInstance(this).cleanup()
|
||||
AgoraManager.getInstance().cleanup()
|
||||
CommonAppContext.getInstance().isPlaying = false
|
||||
CommonAppContext.getInstance().isShow = false
|
||||
QXGiftPlayerManager.getInstance(applicationContext).destroyEffectSvga()
|
||||
@@ -930,9 +943,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
mBinding!!.roomTop.btnFollow.text = "收藏"
|
||||
}
|
||||
if ((roomBean.type_id == "3" || roomBean.type_id == "1" || roomBean.type_id == "4") && roomBean.label_id == "2") {
|
||||
AgoraManager.getInstance(this).isBjMusic = false
|
||||
AgoraManager.getInstance().isBjMusic = false
|
||||
} else {
|
||||
AgoraManager.getInstance(this).isBjMusic = true
|
||||
AgoraManager.getInstance().isBjMusic = true
|
||||
}
|
||||
|
||||
|
||||
@@ -1549,7 +1562,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
} else {
|
||||
if (customMusicFloatingView != null) {
|
||||
customMusicFloatingView!!.destroy()
|
||||
AgoraManager.getInstance(this@RoomActivity).desMusic()
|
||||
AgoraManager.getInstance().desMusic()
|
||||
isMusic = false
|
||||
}
|
||||
|
||||
@@ -1605,20 +1618,20 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
if (customMusicFloatingView != null) {
|
||||
customMusicFloatingView!!.destroy()
|
||||
}
|
||||
AgoraManager.getInstance(this@RoomActivity).desMusic()
|
||||
AgoraManager.getInstance().desMusic()
|
||||
|
||||
if ((mRoomInfoResp!!.room_info.type_id == "1" || mRoomInfoResp!!.room_info.type_id == "4" ||
|
||||
mRoomInfoResp!!.room_info.type_id == "3" || mRoomInfoResp!!.room_info.type_id == "8") &&
|
||||
mRoomInfoResp!!.room_info.label_id == "2"
|
||||
) {
|
||||
for (roomPitBean in mRoomInfoResp!!.song_pit_list) {
|
||||
AgoraManager.getInstance(this@RoomActivity).ClientRole(false)
|
||||
AgoraManager.getInstance().ClientRole(false)
|
||||
ivWheatFeeding(com.xscm.moduleutil.R.mipmap.room_wheat_feeding)
|
||||
mBinding?.rlMic?.visibility = View.GONE
|
||||
}
|
||||
if (mRoomInfoResp!!.song_user_info != null && mRoomInfoResp!!.song_user_info.user_id != null) {
|
||||
if (mRoomInfoResp!!.song_user_info.user_id == SpUtil.getUserId().toString() + "") {
|
||||
AgoraManager.getInstance(this@RoomActivity).ClientRole(false)
|
||||
AgoraManager.getInstance().ClientRole(false)
|
||||
ivWheatFeeding(com.xscm.moduleutil.R.mipmap.room_wheat_feeding)
|
||||
mBinding?.rlMic?.visibility = View.GONE
|
||||
}
|
||||
@@ -1719,7 +1732,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
if (userId == currentUserId && "9" == pitNumber) {
|
||||
if (customMusicFloatingView != null) {
|
||||
customMusicFloatingView!!.destroy()
|
||||
AgoraManager.getInstance(this@RoomActivity).desMusic()
|
||||
AgoraManager.getInstance().desMusic()
|
||||
isMusic = false
|
||||
}
|
||||
mBinding!!.roomTop.rl.visibility = View.GONE
|
||||
@@ -1844,12 +1857,134 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleMsgType1001(messageEvent: RoomMessageEvent) {
|
||||
if (messageEvent.text.fromUserInfo.user_id != SpUtil.getUserId()) {
|
||||
number++
|
||||
// private fun handleMsgType1001(messageEvent: RoomMessageEvent) {
|
||||
// if (messageEvent.text.fromUserInfo.user_id != SpUtil.getUserId()) {
|
||||
// number++
|
||||
// }
|
||||
// mBinding!!.roomTop.tvNum.text = number.toString()
|
||||
// }
|
||||
|
||||
private var currentMqttView: View? = null // 正在播放
|
||||
var decorView: ViewGroup? = null //礼物的
|
||||
|
||||
|
||||
private fun handleMsgType1001(roomMessageEvent: RoomMessageEvent) {
|
||||
if (roomMessageEvent.text.fromUserInfo.enter_image?.isNotEmpty() == true){
|
||||
showFloatingMessage(roomMessageEvent.text.fromUserInfo)
|
||||
}
|
||||
mBinding!!.roomTop.tvNum.text = number.toString()
|
||||
// number++
|
||||
// mBinding!!.roomTop.tvNum.text = number.toString() + ""
|
||||
}
|
||||
private fun showFloatingMessage(userInfo: UserInfo) {
|
||||
try {
|
||||
// 清理之前的视图(如果存在)
|
||||
if ( currentMqttView?.getParent() != null) {
|
||||
val parent = currentMqttView?.getParent() as ViewGroup
|
||||
parent.removeView(currentMqttView)
|
||||
}
|
||||
|
||||
if (decorView == null) {
|
||||
decorView = getWindow().getDecorView() as ViewGroup?
|
||||
}
|
||||
|
||||
currentMqttView = LayoutInflater.from(this).inflate(R.layout.item_noble_piaoping, null)
|
||||
val layoutParams = FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
layoutParams.topMargin = DisplayUtil.dip2px(this, 300f)
|
||||
layoutParams.gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
|
||||
currentMqttView?.setLayoutParams(layoutParams)
|
||||
decorView?.addView(currentMqttView)
|
||||
currentMqttView?.let { updateFloatingViewData(it, userInfo) }
|
||||
|
||||
currentMqttView?.let {
|
||||
resetAndStartMqttAnimation(it, Runnable {
|
||||
// 清理当前视图
|
||||
if (currentMqttView?.getParent() != null) {
|
||||
val parent = currentMqttView?.getParent() as ViewGroup
|
||||
parent.removeView(currentMqttView)
|
||||
}
|
||||
currentMqttView = null
|
||||
|
||||
})
|
||||
}
|
||||
} catch (e: java.lang.Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
private fun resetAndStartMqttAnimation(view: View, onAnimationEnd: Runnable) {
|
||||
try {
|
||||
val screenWidth = getScreenWidth()
|
||||
// 设置初始位置:在屏幕右侧外部(完全不可见)
|
||||
view.setTranslationX(screenWidth.toFloat())
|
||||
|
||||
|
||||
val enterAnim = TranslateAnimation(
|
||||
Animation.ABSOLUTE, screenWidth.toFloat(),
|
||||
Animation.ABSOLUTE, ((screenWidth - SystemUtils.getWidth(316)) / 2).toFloat(),
|
||||
Animation.ABSOLUTE, 0f,
|
||||
Animation.ABSOLUTE, 0f
|
||||
)
|
||||
enterAnim.setDuration(1500)
|
||||
enterAnim.setInterpolator(DecelerateInterpolator(2.0f))
|
||||
enterAnim.setAnimationListener(object : Animation.AnimationListener {
|
||||
override fun onAnimationStart(animation: Animation?) {
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
// 停留后退出
|
||||
CommonAppContext.postDelayed(Runnable {
|
||||
val exitAnim = TranslateAnimation(
|
||||
Animation.ABSOLUTE, ((screenWidth - SystemUtils.getWidth(316)) / 2).toFloat(),
|
||||
Animation.ABSOLUTE, -screenWidth.toFloat(),
|
||||
Animation.ABSOLUTE, 0f,
|
||||
Animation.ABSOLUTE, 0f
|
||||
)
|
||||
exitAnim.setDuration(3000)
|
||||
exitAnim.setInterpolator(DecelerateInterpolator(2f))
|
||||
exitAnim.setAnimationListener(object : Animation.AnimationListener {
|
||||
override fun onAnimationStart(animation: Animation?) {
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
// 移除视图并处理下一个
|
||||
onAnimationEnd.run()
|
||||
}
|
||||
|
||||
override fun onAnimationRepeat(animation: Animation?) {
|
||||
}
|
||||
})
|
||||
view.startAnimation(exitAnim)
|
||||
}, 5000) // 停留1秒
|
||||
}
|
||||
|
||||
override fun onAnimationRepeat(animation: Animation?) {
|
||||
}
|
||||
})
|
||||
view.startAnimation(enterAnim)
|
||||
} catch (e: java.lang.Exception) {
|
||||
LogUtils.e("MQTT动画启动失败", e)
|
||||
onAnimationEnd.run()
|
||||
}
|
||||
}
|
||||
private fun getScreenWidth(): Int {
|
||||
val displayMetrics = DisplayMetrics()
|
||||
if (getWindowManager() != null) {
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics)
|
||||
return displayMetrics.widthPixels
|
||||
}
|
||||
return getResources().getDisplayMetrics().widthPixels
|
||||
}
|
||||
|
||||
private fun updateFloatingViewData(view: View, userInfo: UserInfo) {
|
||||
val textView = view.findViewById<TextView?>(R.id.tv_name)
|
||||
val im_bj = view.findViewById<ImageView?>(R.id.im_bj)
|
||||
|
||||
textView.text = userInfo.enter_text
|
||||
ImageUtils.loadHeadCC(userInfo.enter_image, im_bj)
|
||||
}
|
||||
|
||||
|
||||
private fun handleMsgType1002(messageEvent: RoomMessageEvent, text: T?) {
|
||||
number--
|
||||
@@ -1965,7 +2100,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
MessageListenerSingleton.getInstance().joinGroup(pendingRoomId)
|
||||
MvpPre!!.getRoomIn(pendingRoomId, "")
|
||||
lastSwitchedRoomId = pendingRoomId!!
|
||||
AgoraManager.getInstance(OkDownloadProvider.context).lastRoomId =
|
||||
AgoraManager.getInstance().lastRoomId =
|
||||
messageEvent.roomId
|
||||
}
|
||||
}
|
||||
@@ -2057,9 +2192,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
val parsedText: RoomMessageEvent.text =
|
||||
GsonUtils.fromJson(text, RoomMessageEvent.text::class.java)
|
||||
if (parsedText.is_mute == 1) {
|
||||
AgoraManagerEx.getInstance(this).muteLocalAudioStreamEx(true)
|
||||
AgoraManagerEx.getInstance().muteLocalAudioStreamEx(true)
|
||||
} else {
|
||||
AgoraManagerEx.getInstance(this).muteLocalAudioStreamEx(false)
|
||||
AgoraManagerEx.getInstance().muteLocalAudioStreamEx(false)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
// Handle exception
|
||||
@@ -2098,7 +2233,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
private fun handleMsgType126(messageEvent: RoomMessageEvent, text: T?) {
|
||||
if (text == null) return
|
||||
|
||||
AgoraManager.getInstance(this)
|
||||
AgoraManager.getInstance()
|
||||
.setLocalAudioEnabled(false, text.fromUserInfo.user_id.toString() + "")
|
||||
}
|
||||
|
||||
@@ -2291,7 +2426,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
mBinding!!.imVoive.setImageResource(com.xscm.moduleutil.R.mipmap.room_voice_kg)
|
||||
voive = true
|
||||
}
|
||||
AgoraManager.getInstance(this).muteSpeaker(!voive)
|
||||
AgoraManager.getInstance().muteSpeaker(!voive)
|
||||
} else if (id == R.id.rl_more) { //点击PK
|
||||
val fragment = RoomPkDialogFragment.newInstance(
|
||||
roomId,
|
||||
@@ -2414,7 +2549,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
CommonAppContext.getInstance().isPlaying = false
|
||||
CommonAppContext.getInstance().isShow = false
|
||||
QXGiftPlayerManager.getInstance(this).destroyEffectSvga()
|
||||
AgoraManager.getInstance(this).cleanup()
|
||||
AgoraManager.getInstance().cleanup()
|
||||
|
||||
MyRoomSingleton.getInstance().onExitRoom()
|
||||
MessageListenerSingleton.quitGroup(roomId)
|
||||
@@ -2518,15 +2653,15 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
fun switchMic(type: Int) {
|
||||
if (type == 1) {
|
||||
mBinding!!.ivMic.setImageResource(com.xscm.moduleutil.R.mipmap.room_microphone)
|
||||
AgoraManager.getInstance(this)
|
||||
AgoraManager.getInstance()
|
||||
.setLocalAudioEnabled(true, SpUtil.getUserId().toString() + "")
|
||||
isSwith = false
|
||||
AgoraManager.getInstance(this).muteLocalAudioStream(false)
|
||||
AgoraManager.getInstance(this).ClientRole(true)
|
||||
AgoraManager.getInstance().muteLocalAudioStream(false)
|
||||
AgoraManager.getInstance().ClientRole(true)
|
||||
CommonAppContext.getInstance().isMai = true
|
||||
} else {
|
||||
mBinding!!.ivMic.setImageResource(com.xscm.moduleutil.R.mipmap.room_microphone_off)
|
||||
AgoraManager.getInstance(this)
|
||||
AgoraManager.getInstance()
|
||||
.setLocalAudioEnabled(false, SpUtil.getUserId().toString() + "")
|
||||
isSwith = true
|
||||
isMute(1)
|
||||
@@ -2611,7 +2746,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
val typeId = mRoomInfoResp!!.room_info.type_id
|
||||
val labelId = mRoomInfoResp!!.room_info.label_id
|
||||
val userPitNumber = mRoomInfoResp!!.user_info.pit_number
|
||||
val userPitNumber = mRoomInfoResp?.user_info?.pit_number!!
|
||||
|
||||
// 情况1: typeId = 6 时,只显示消息按钮
|
||||
if ("6" == typeId) {
|
||||
@@ -2938,9 +3073,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
// mBinding.roomTop.btnFollow.setBackground(getResources().getDrawable(com.xscm.moduleutil.R.mipmap.collect));
|
||||
}
|
||||
if ((roomBean.type_id == "3" || roomBean.type_id == "1" || roomBean.type_id == "4") && roomBean.label_id == "2") {
|
||||
AgoraManager.getInstance(this).isBjMusic = false
|
||||
AgoraManager.getInstance().isBjMusic = false
|
||||
} else {
|
||||
AgoraManager.getInstance(this).isBjMusic = true
|
||||
AgoraManager.getInstance().isBjMusic = true
|
||||
}
|
||||
|
||||
AgoraManager.stopMuisc()
|
||||
@@ -3016,7 +3151,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
ivSoundEffects(false)
|
||||
}
|
||||
// }
|
||||
if (mRoomInfoResp!!.user_info.user_id == SpUtil.getUserId()
|
||||
if (mRoomInfoResp?.user_info?.user_id == SpUtil.getUserId()
|
||||
&& mRoomInfoResp!!.user_info.pit_number == 9
|
||||
&& mRoomInfoResp!!.room_info.type_id != "2"
|
||||
&& mRoomInfoResp!!.room_info.type_id != "6"
|
||||
@@ -3162,13 +3297,13 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
*/
|
||||
fun initializeAudio() {
|
||||
if (mRoomUserBean!!.pit_number != 0) {
|
||||
AgoraManager.getInstance(this).ClientRole(true)
|
||||
AgoraManager.getInstance(this).muteLocalAudioStream(false)
|
||||
AgoraManager.getInstance().ClientRole(true)
|
||||
AgoraManager.getInstance().muteLocalAudioStream(false)
|
||||
} else {
|
||||
AgoraManager.getInstance(this).ClientRole(false)
|
||||
AgoraManager.getInstance(this).muteLocalAudioStream(true)
|
||||
AgoraManager.getInstance().ClientRole(false)
|
||||
AgoraManager.getInstance().muteLocalAudioStream(true)
|
||||
}
|
||||
AgoraManager.getInstance(this)
|
||||
AgoraManager.getInstance()
|
||||
.setLocalAudioEnabled(false, SpUtil.getUserId().toString() + "")
|
||||
}
|
||||
|
||||
@@ -3385,7 +3520,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
customMusicFloatingView!!.setOnItemClickListener(object : OnMusicItemClickListener {
|
||||
override fun onMinimize() {
|
||||
customMusicFloatingView!!.destroy()
|
||||
AgoraManager.getInstance(this@RoomActivity).desMusic()
|
||||
AgoraManager.getInstance().desMusic()
|
||||
isMusic = false
|
||||
}
|
||||
|
||||
@@ -3398,20 +3533,20 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
override fun onPause() {
|
||||
// ToastUtils.showShort("暂停播放");
|
||||
// 调用播放器或通知 MusicView
|
||||
AgoraManager.getInstance(this@RoomActivity).pauseMusic()
|
||||
AgoraManager.getInstance().pauseMusic()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
// ToastUtils.showShort("恢复播放");
|
||||
// 调用播放器或通知 MusicView
|
||||
AgoraManager.getInstance(this@RoomActivity).resumeMusic()
|
||||
AgoraManager.getInstance().resumeMusic()
|
||||
}
|
||||
|
||||
override fun onNext() {
|
||||
// ToastUtils.showShort("下一首");
|
||||
// 切换歌曲
|
||||
// List<Music> musicSongBeans = AgoraManager.getInstance(RoomActivity.this).getMusicList();
|
||||
AgoraManager.nextSong()
|
||||
AgoraManager.getInstance().nextSong()
|
||||
}
|
||||
})
|
||||
// customMusicFloatingView.initView();
|
||||
@@ -3484,8 +3619,8 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
// 恢复音频状态
|
||||
if (AgoraManager.getInstance(this) != null) {
|
||||
AgoraManager.getInstance(this).resumeMusic()
|
||||
if (AgoraManager.getInstance() != null) {
|
||||
AgoraManager.getInstance().resumeMusic()
|
||||
}
|
||||
|
||||
// 清除最小化状态标志
|
||||
@@ -3732,7 +3867,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
fun quit() {
|
||||
CommonAppContext.getInstance().isPlaying = false
|
||||
CommonAppContext.getInstance().isShow = false
|
||||
AgoraManager.getInstance(this).cleanup()
|
||||
AgoraManager.getInstance().cleanup()
|
||||
MyRoomSingleton.getInstance().onExitRoom()
|
||||
}
|
||||
|
||||
@@ -3743,10 +3878,10 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
fun jiaR() {
|
||||
LogUtils.e(
|
||||
"@@@",
|
||||
"上一个房间的roonid" + AgoraManager.getInstance(OkDownloadProvider.context).lastRoomId
|
||||
"上一个房间的roonid" + AgoraManager.getInstance().lastRoomId
|
||||
)
|
||||
MvpPre?.getRoomIn(AgoraManager.getInstance(OkDownloadProvider.context).lastRoomId, "")
|
||||
AgoraManager.getInstance(OkDownloadProvider.context).lastRoomId = ""
|
||||
MvpPre?.getRoomIn(AgoraManager.getInstance().lastRoomId, "")
|
||||
AgoraManager.getInstance().lastRoomId = ""
|
||||
}
|
||||
|
||||
override fun userGuanzSuccess(s: String) {
|
||||
@@ -3844,6 +3979,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
GiftDisplayManager.getInstance().clearAll()
|
||||
mBinding!!.giftContainer.removeAllViews()
|
||||
CommonAppContext.getInstance().isMai = false
|
||||
CommonAppContext.getInstance().playId = null
|
||||
|
||||
// 确保父类的 onDestroy 被调用
|
||||
super.finish()
|
||||
}
|
||||
@@ -3880,8 +4018,8 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
// 6. 清理 Agora 资源
|
||||
// if (AgoraManager.getInstance(this) != null) {
|
||||
// AgoraManager.getInstance(this).cleanup();
|
||||
// if (AgoraManager.getInstance() != null) {
|
||||
// AgoraManager.getInstance().cleanup();
|
||||
// }
|
||||
// 清理所有弹框
|
||||
dismissAllDialogs()
|
||||
|
||||
@@ -90,6 +90,11 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
onFragmentShowDestroy();
|
||||
// 清理消息队列,避免内存泄漏
|
||||
synchronized (queueLock) {
|
||||
messageQueue.clear();
|
||||
messageHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@@ -438,34 +443,37 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
|
||||
}
|
||||
|
||||
// 使用Handler将消息处理放到消息队列中,避免阻塞
|
||||
if (messageHandler.hasMessages(MSG_HANDLE_ROOM_MESSAGE)) {
|
||||
// 如果队列中已有待处理消息,将当前消息加入队列
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_HANDLE_ROOM_MESSAGE;
|
||||
msg.obj = message;
|
||||
messageHandler.sendMessage(msg);
|
||||
} else {
|
||||
// 立即处理第一条消息
|
||||
processRoomMessage(message);
|
||||
// 标记有待处理消息
|
||||
messageHandler.sendEmptyMessageDelayed(MSG_HANDLE_ROOM_MESSAGE, 100);
|
||||
synchronized (queueLock) {
|
||||
if (messageHandler.hasMessages(MSG_HANDLE_ROOM_MESSAGE)) {
|
||||
// 如果队列中已有待处理消息,将当前消息加入队列
|
||||
messageQueue.add(message);
|
||||
} else {
|
||||
// 立即处理第一条消息
|
||||
processRoomMessage(message);
|
||||
// 标记有待处理消息
|
||||
messageHandler.sendEmptyMessageDelayed(MSG_HANDLE_ROOM_MESSAGE, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final int MSG_HANDLE_ROOM_MESSAGE = 1001;
|
||||
private final Handler messageHandler = new Handler(Looper.getMainLooper()) {
|
||||
private List<RoomMessageEvent> messageQueue = new ArrayList<>();
|
||||
// 将messageQueue移到类级别,并添加同步控制
|
||||
private final List<RoomMessageEvent> messageQueue = new ArrayList<>();
|
||||
private final Object queueLock = new Object(); // 用于同步的锁对象
|
||||
|
||||
private final Handler messageHandler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(@NonNull Message msg) {
|
||||
if (msg.what == MSG_HANDLE_ROOM_MESSAGE) {
|
||||
if (!messageQueue.isEmpty()) {
|
||||
// 批量处理消息
|
||||
processBatchMessages(messageQueue);
|
||||
messageQueue.clear();
|
||||
} else if (msg.obj instanceof RoomMessageEvent) {
|
||||
// 处理单条消息
|
||||
processRoomMessage((RoomMessageEvent) msg.obj);
|
||||
synchronized (queueLock) {
|
||||
if (!messageQueue.isEmpty()) {
|
||||
// 批量处理消息
|
||||
processBatchMessages(new ArrayList<>(messageQueue)); // 创建副本避免并发修改
|
||||
messageQueue.clear();
|
||||
} else if (msg.obj instanceof RoomMessageEvent) {
|
||||
// 处理单条消息
|
||||
processRoomMessage((RoomMessageEvent) msg.obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -899,7 +899,7 @@ public class FriendshipRoomFragment extends BaseRoomFragment<FriendshipRoomPrese
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).setrlMic(false);
|
||||
((RoomActivity) getActivity()).ivWheatFeeding(com.xscm.moduleutil.R.mipmap.room_wheat_feeding);
|
||||
AgoraManager.getInstance(getActivity()).setLocalAudioEnabled(false, SpUtil.getUserId() + "");
|
||||
AgoraManager.getInstance().setLocalAudioEnabled(false, SpUtil.getUserId() + "");
|
||||
}
|
||||
} else {
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
|
||||
@@ -131,10 +131,10 @@ public class MusicSongListFragment extends BaseMvpFragment<RequestPresenter, Fra
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
boolean b = AgoraManager.getInstance(getContext()).isBjMusic();
|
||||
boolean b = AgoraManager.getInstance().isBjMusic();
|
||||
if (b) {
|
||||
List<MusicSongBean> musicSongBeans = new ArrayList<>();
|
||||
List<Music> music = AgoraManager.getInstance(getContext()).getMusicList();
|
||||
List<Music> music = AgoraManager.getInstance().getMusicList();
|
||||
if (music != null && music.size() > 0) {
|
||||
for (int i = 0; i < music.size(); i++) {
|
||||
MusicSongBean musicSongBean = new MusicSongBean();
|
||||
|
||||
@@ -131,7 +131,7 @@ public class RequestFragment extends BaseMvpFragment<RequestPresenter, FragmentR
|
||||
public void afterTextChanged(Editable s) {
|
||||
input = s.toString();
|
||||
SpUtil.setMusicName( input);
|
||||
AgoraManager.getInstance(getContext()).searchMusic(input, 1);
|
||||
AgoraManager.getInstance().searchMusic(input, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -142,13 +142,13 @@ public class RequestFragment extends BaseMvpFragment<RequestPresenter, FragmentR
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
AgoraManager.getInstance(getContext()).searchMusic(mBinding.editQuery.getText().toString(), page);
|
||||
AgoraManager.getInstance().searchMusic(mBinding.editQuery.getText().toString(), page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
AgoraManager.getInstance(getContext()).searchMusic(mBinding.editQuery.getText().toString(), page);
|
||||
AgoraManager.getInstance().searchMusic(mBinding.editQuery.getText().toString(), page);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -170,18 +170,18 @@ public class RequestFragment extends BaseMvpFragment<RequestPresenter, FragmentR
|
||||
if (status==1) {
|
||||
MvpPre.song(roomId, SpUtil.getUserId() + "", item.getSongCode() + "", item.getName(), item.getSinger(), item.getPoster(), String.valueOf(item.getDurationS()));
|
||||
} else {
|
||||
if (AgoraManager.getInstance(getContext()).getMusicList()==null) {
|
||||
// AgoraManager.getInstance(getContext()).isPreload2(item.getSongCode(), 1);
|
||||
if (AgoraManager.getInstance().getMusicList()==null) {
|
||||
// AgoraManager.getInstance().isPreload(item.getSongCode(), 1);
|
||||
List<Music> music = new ArrayList<>();
|
||||
music.add(item);
|
||||
AgoraManager.getInstance(getContext()).setMusicList(music);
|
||||
AgoraManager.getInstance().setMusicList(music);
|
||||
EventBus.getDefault().post(item);
|
||||
AgoraManager.getInstance(getContext()).nextSong();
|
||||
AgoraManager.getInstance().nextSong();
|
||||
} else {
|
||||
|
||||
List<Music> music = AgoraManager.getInstance(getContext()).getMusicList();
|
||||
List<Music> music = AgoraManager.getInstance().getMusicList();
|
||||
music.add(item);
|
||||
AgoraManager.getInstance(getContext()).setMusicList(music);
|
||||
AgoraManager.getInstance().setMusicList(music);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
} else {
|
||||
isMicPlace = false;
|
||||
ToastUtils.show("将停止屏幕共享");
|
||||
AgoraManager.getInstance(getActivity()).stopScreenCapture();
|
||||
AgoraManager.getInstance().stopScreenCapture();
|
||||
mBinding.im3.setImageResource(com.xscm.moduleutil.R.mipmap.gongxiang);
|
||||
CommonAppContext.getInstance().isMicPlace = false;
|
||||
}
|
||||
@@ -282,17 +282,17 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
|
||||
if (type == 1) {
|
||||
mBinding.im1.setImageResource(com.xscm.moduleutil.R.mipmap.close_m);
|
||||
AgoraManager.getInstance(getActivity()).ClientRole(true);
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(false);
|
||||
AgoraManager.getInstance(getActivity()).setLocalAudioEnabled(true,SpUtil.getUserId()+"");
|
||||
AgoraManager.getInstance().ClientRole(true);
|
||||
AgoraManager.getInstance().muteLocalAudioStream(false);
|
||||
AgoraManager.getInstance().setLocalAudioEnabled(true,SpUtil.getUserId()+"");
|
||||
isShow = false;
|
||||
CommonAppContext.getInstance().isShowAg=false;
|
||||
|
||||
} else {
|
||||
mBinding.im1.setImageResource(com.xscm.moduleutil.R.mipmap.op_m);
|
||||
AgoraManager.getInstance(getActivity()).ClientRole(true);
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(true);
|
||||
AgoraManager.getInstance(getActivity()).setLocalAudioEnabled(false,SpUtil.getUserId()+"");
|
||||
AgoraManager.getInstance().ClientRole(true);
|
||||
AgoraManager.getInstance().muteLocalAudioStream(true);
|
||||
AgoraManager.getInstance().setLocalAudioEnabled(false,SpUtil.getUserId()+"");
|
||||
isShow = true;
|
||||
CommonAppContext.getInstance().isShowAg=true;
|
||||
|
||||
@@ -362,7 +362,7 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
// 调用退出房间方法
|
||||
if (label_id!=null && label_id.equals(LABEL_ID_MOVIE)){
|
||||
MvpPre.quitRoom(roomId, SpUtil.getUserId() + "");
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", AgoraManager.getInstance(getActivity()).getLastRoomId()).navigation();
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", AgoraManager.getInstance().getLastRoomId()).navigation();
|
||||
return;
|
||||
}
|
||||
if (roomInfoResp != null) {
|
||||
@@ -583,7 +583,7 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
((RoomActivity) getActivity()).quitRoom2(roomId);
|
||||
if (label_id!=null && label_id.equals(LABEL_ID_MOVIE)){
|
||||
((RoomActivity) getActivity()).jiaR();
|
||||
//// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", AgoraManager.getInstance(getActivity()).getLastRoomId()).navigation();
|
||||
//// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", AgoraManager.getInstance().getLastRoomId()).navigation();
|
||||
return;
|
||||
}else {
|
||||
((RoomActivity) getActivity()).performExitRoom(1);
|
||||
@@ -616,8 +616,8 @@ public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, Room
|
||||
|
||||
private void joinChannel() {
|
||||
|
||||
AgoraManager.getInstance(getActivity()).updateChannelMediaOptions();
|
||||
AgoraManager.getInstance(getActivity()).post();
|
||||
AgoraManager.getInstance().updateChannelMediaOptions();
|
||||
AgoraManager.getInstance().post();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -418,9 +418,9 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
||||
|
||||
if (mRoomInfoResp.getUser_info().getPit_number() != 0) {
|
||||
mRoomActivity.switchMic(CommonAppContext.getInstance().isMai?1:2);
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(CommonAppContext.getInstance().isMai);
|
||||
AgoraManager.getInstance().muteLocalAudioStream(CommonAppContext.getInstance().isMai);
|
||||
} else {
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(true);
|
||||
AgoraManager.getInstance().muteLocalAudioStream(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
||||
if (existingFragment != null) {
|
||||
transaction.show(existingFragment);
|
||||
} else {
|
||||
callSpecificDestroyMethod(newFragment);
|
||||
// callSpecificDestroyMethod(newFragment);
|
||||
transaction.add(containerId, newFragment, tag);
|
||||
}
|
||||
transaction.commitAllowingStateLoss();
|
||||
@@ -765,12 +765,12 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
RoomActivity roomActivity = (RoomActivity) getActivity();
|
||||
if (!haveMe) {
|
||||
AgoraManager.getInstance(getContext()).ClientRole(false);
|
||||
AgoraManager.getInstance().ClientRole(false);
|
||||
roomActivity.setrlMic(false);
|
||||
AgoraManager.getInstance(getContext()).setLocalAudioEnabled(false, SpUtil.getUserId() + "");
|
||||
AgoraManager.getInstance().setLocalAudioEnabled(false, SpUtil.getUserId() + "");
|
||||
} else {
|
||||
roomActivity.setrlMic(true);
|
||||
if (AgoraManager.getInstance(getContext()).isLocalAudioEnabled()) {
|
||||
if (AgoraManager.getInstance().isLocalAudioEnabled()) {
|
||||
roomActivity.ivMic(com.xscm.moduleutil.R.mipmap.room_microphone);
|
||||
} else {
|
||||
// roomActivity.ivMic(com.xscm.moduleutil.R.mipmap.room_microphone_off);
|
||||
@@ -779,9 +779,9 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
||||
}
|
||||
} else {
|
||||
if (!user_id.equals(SpUtil.getUserId() + "") && getActivity() instanceof RoomActivity) {
|
||||
AgoraManager.getInstance(getContext()).ClientRole(false);
|
||||
AgoraManager.getInstance().ClientRole(false);
|
||||
((RoomActivity) getActivity()).setrlMic(false);
|
||||
AgoraManager.getInstance(getContext()).setLocalAudioEnabled(false, SpUtil.getUserId() + "");
|
||||
AgoraManager.getInstance().setLocalAudioEnabled(false, SpUtil.getUserId() + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,10 +126,10 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
||||
did = roomInfoResp.getSong_user_info().getDid();
|
||||
if (roomInfoResp.getSong_user_info().getUser_id().equals(SpUtil.getUserId() + "")) {
|
||||
setBz();
|
||||
AgoraManager.getInstance(getActivity()).isPreload(Long.parseLong(roomInfoResp.getSong_user_info().getSong_code()), 1);
|
||||
AgoraManager.getInstance().isPreload(Long.parseLong(roomInfoResp.getSong_user_info().getSong_code()), 1);
|
||||
} else {
|
||||
if (AgoraManager.getInstance(getActivity()).isOnJoin()) {
|
||||
AgoraManager.getInstance(getActivity()).loadLrc(Long.parseLong(roomInfoResp.getSong_user_info().getSong_code()));
|
||||
if (AgoraManager.getInstance().isOnJoin()) {
|
||||
AgoraManager.getInstance().loadLrc(Long.parseLong(roomInfoResp.getSong_user_info().getSong_code()));
|
||||
}
|
||||
}
|
||||
musicSongBean = roomInfoResp.getSong_user_info();
|
||||
@@ -200,12 +200,12 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
||||
|
||||
private void setBz(){
|
||||
if (volumeManager.getBz(SpUtil.getUserId()+"")){
|
||||
AgoraManager.getInstance(getActivity()).selectAudioTrack(0);
|
||||
AgoraManager.getInstance().selectAudioTrack(0);
|
||||
mBinding.imBz.setImageResource(com.xscm.moduleutil.R.mipmap.accompany_on);
|
||||
mBinding.tvBz.setText("原唱");
|
||||
isRotate = false;
|
||||
}else {
|
||||
AgoraManager.getInstance(getActivity()).selectAudioTrack(1);
|
||||
AgoraManager.getInstance().selectAudioTrack(1);
|
||||
mBinding.imBz.setImageResource(com.xscm.moduleutil.R.mipmap.accompany_off);
|
||||
mBinding.tvBz.setText("伴奏");
|
||||
isRotate = true;
|
||||
@@ -218,8 +218,8 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
||||
int[] volumes = volumeManager.getUserVolumes(SpUtil.getUserId()+"");
|
||||
int musicVolume = volumes[0];
|
||||
int playoutVolume = volumes[1];
|
||||
AgoraManager.getInstance(getContext()).setMusicVolume(musicVolume); // 使用原始值(0-200
|
||||
AgoraManager.getInstance(getContext()).setPlayoutVolume(playoutVolume);
|
||||
AgoraManager.getInstance().setMusicVolume(musicVolume); // 使用原始值(0-200
|
||||
AgoraManager.getInstance().setPlayoutVolume(playoutVolume);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -515,7 +515,7 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
||||
ToastUtils.showShort("暂时没有歌曲");
|
||||
return;
|
||||
}
|
||||
AgoraManager.getInstance(getActivity()).stopMuisc();
|
||||
AgoraManager.getInstance().stopMuisc();
|
||||
MvpPre.changeSong(roomInfoResp.getRoom_info().getRoom_id(), did);
|
||||
} else if (id == R.id.ll_ds) {
|
||||
if (mBinding.muYc.pitBean.getUser_id() != null && !mBinding.muYc.pitBean.getUser_id().equals("")) {
|
||||
@@ -530,13 +530,13 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
||||
}
|
||||
} else if (id == R.id.ll_bz) {
|
||||
if (isRotate) {
|
||||
AgoraManager.getInstance(getActivity()).selectAudioTrack(0);
|
||||
AgoraManager.getInstance().selectAudioTrack(0);
|
||||
mBinding.imBz.setImageResource(com.xscm.moduleutil.R.mipmap.accompany_on);
|
||||
mBinding.tvBz.setText("原唱");
|
||||
isRotate = false;
|
||||
volumeManager.saveBz(SpUtil.getUserId()+"",true);
|
||||
} else {
|
||||
AgoraManager.getInstance(getActivity()).selectAudioTrack(1);
|
||||
AgoraManager.getInstance().selectAudioTrack(1);
|
||||
mBinding.imBz.setImageResource(com.xscm.moduleutil.R.mipmap.accompany_off);
|
||||
mBinding.tvBz.setText("伴奏");
|
||||
isRotate = true;
|
||||
@@ -607,7 +607,7 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
||||
position += 1000;
|
||||
double duration = Math.ceil(position / 1000);
|
||||
if (duration >= Double.parseDouble(musicSongBean.getDuration())) {
|
||||
AgoraManager.getInstance(getActivity()).stopMuisc();
|
||||
AgoraManager.getInstance().stopMuisc();
|
||||
MvpPre.changeSong(roomInfoResp.getRoom_info().getRoom_id(), did);
|
||||
}
|
||||
}
|
||||
@@ -647,17 +647,17 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
||||
roomInfoResp.setSong_user_info(musicSongBean);
|
||||
|
||||
if (messageEvent.getText().getSongInfo().getUser_id().equals(SpUtil.getUserId() + "")) {
|
||||
AgoraManager.getInstance(getActivity());
|
||||
AgoraManager.getInstance();
|
||||
AgoraManager.stopMuisc();
|
||||
LogUtils.e("推送过来的code", messageEvent.getText().getSongInfo().getSong_code());
|
||||
AgoraManager.getInstance(getActivity()).isPreload(Long.parseLong(messageEvent.getText().getSongInfo().getSong_code()), 1);
|
||||
AgoraManager.getInstance().isPreload(Long.parseLong(messageEvent.getText().getSongInfo().getSong_code()), 1);
|
||||
setAgorVolumes();
|
||||
} else {
|
||||
volumeManager.saveBz(SpUtil.getUserId()+"",true);
|
||||
volumeManager.clearCurrentVolumes();
|
||||
|
||||
if (AgoraManager.getInstance(getActivity()).isOnJoin()) {
|
||||
AgoraManager.getInstance(getActivity()).loadLrc(Long.parseLong(roomInfoResp.getSong_user_info().getSong_code()));
|
||||
if (AgoraManager.getInstance().isOnJoin()) {
|
||||
AgoraManager.getInstance().loadLrc(Long.parseLong(roomInfoResp.getSong_user_info().getSong_code()));
|
||||
}
|
||||
}
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
@@ -724,8 +724,8 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
||||
}
|
||||
if (SpUtil.getUserId() == messageEvent.getText().getFromUserInfo().getUser_id()) {
|
||||
b = true;
|
||||
AgoraManager.getInstance(getActivity()).ClientRole(true);
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(false);
|
||||
AgoraManager.getInstance().ClientRole(true);
|
||||
AgoraManager.getInstance().muteLocalAudioStream(false);
|
||||
} else {
|
||||
b = false;
|
||||
}
|
||||
@@ -766,8 +766,8 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
||||
}
|
||||
if (SpUtil.getUserId() == messageEvent.getText().getFromUserInfo().getUser_id()) {
|
||||
b = true;
|
||||
AgoraManager.getInstance(getActivity()).ClientRole(false);
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(true);
|
||||
AgoraManager.getInstance().ClientRole(false);
|
||||
AgoraManager.getInstance().muteLocalAudioStream(true);
|
||||
} else {
|
||||
b = false;
|
||||
}
|
||||
|
||||
@@ -554,12 +554,12 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
mBinding.imMkf.setImageResource(com.xscm.moduleutil.R.mipmap.room_microphone);
|
||||
is_mute = 0;
|
||||
aBoolean = false;
|
||||
AgoraManagerEx.getInstance(getActivity()).muteAllRemoteAudioStreamsExUserId(false);
|
||||
AgoraManager.getInstance().muteAllRemoteAudioStreamsExUserId(false);
|
||||
} else {
|
||||
mBinding.imMkf.setImageResource(com.xscm.moduleutil.R.mipmap.room_microphone_off);
|
||||
is_mute = 1;
|
||||
aBoolean = true;
|
||||
AgoraManagerEx.getInstance(getActivity()).muteAllRemoteAudioStreamsExUserId(true);
|
||||
AgoraManager.getInstance().muteAllRemoteAudioStreamsExUserId(true);
|
||||
}
|
||||
RoomMessageEvent.text text = new RoomMessageEvent.text();
|
||||
text.setIs_mute(is_mute);
|
||||
@@ -662,7 +662,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
LogUtils.e("pk_info", "" + roomInfoRespPk.getRoom_info().getRoom_id());
|
||||
LogUtils.e("pk_info2", "" + roomInfoResp.getRoom_info().getRoom_id());
|
||||
|
||||
AgoraManagerEx.getInstance(CommonAppContext.getInstance())
|
||||
AgoraManagerEx.getInstance()
|
||||
.joinChannelEx(pkSwTokenBean.getAgora_token(), roomInfoRespPk.getRoom_info().getRoom_id(), pkUserId);
|
||||
}
|
||||
|
||||
@@ -1075,6 +1075,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
pitBean.setSex(message.getText().getFromUserInfo().getSex() + "");
|
||||
pitBean.setCharm(message.getText().getFromUserInfo().getCharm());
|
||||
pitBean.setDress(message.getText().getFromUserInfo().getDress());
|
||||
pitBean.setMic_cycle(message.getText().getFromUserInfo().getMic_cycle()!=null?message.getText().getFromUserInfo().getMic_cycle():"");
|
||||
roomInfoResp.getRoom_info().getPit_list().set(Integer.parseInt(message.getText().getPit_number()) - 1, pitBean);
|
||||
if (roomInfoRespPk == null || roomInfoRespPk.getPk_info() == null) {
|
||||
wheatLayoutSingManager.updateSingleWheat(pitBean, Integer.parseInt(message.getText().getPit_number()));
|
||||
@@ -1088,8 +1089,8 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
// 通知父 Fragment
|
||||
if (SpUtil.getUserId() == message.getText().getFromUserInfo().getUser_id()) {
|
||||
b = true;
|
||||
AgoraManager.getInstance(getActivity()).ClientRole(true);
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(false);
|
||||
AgoraManager.getInstance().ClientRole(true);
|
||||
AgoraManager.getInstance().muteLocalAudioStream(false);
|
||||
} else {
|
||||
b = false;
|
||||
}
|
||||
@@ -1108,6 +1109,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
pitBean.setSex("");
|
||||
pitBean.setCharm("");
|
||||
pitBean.setDress("");
|
||||
pitBean.setMic_cycle("");
|
||||
roomInfoResp.getRoom_info().getPit_list().set(Integer.parseInt(message.getText().getPit_number()) - 1, pitBean);
|
||||
if (roomInfoRespPk == null || roomInfoRespPk.getPk_info() == null) {
|
||||
wheatLayoutSingManager.updateSingleWheat(pitBean, Integer.parseInt(message.getText().getPit_number()));
|
||||
@@ -1120,8 +1122,8 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
}
|
||||
if (SpUtil.getUserId() == message.getText().getFromUserInfo().getUser_id()) {
|
||||
b = true;
|
||||
AgoraManager.getInstance(getActivity()).ClientRole(false);
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(true);
|
||||
AgoraManager.getInstance().ClientRole(false);
|
||||
AgoraManager.getInstance().muteLocalAudioStream(true);
|
||||
} else {
|
||||
b = false;
|
||||
}
|
||||
@@ -1218,7 +1220,7 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
//释放定时器
|
||||
releaseCountDownTimer();
|
||||
if (roomInfoRespPk.getRoom_info() != null && roomInfoRespPk.getRoom_info().getRoom_id() != null) {
|
||||
AgoraManagerEx.getInstance(getContext()).leaveChannelEx(roomInfoRespPk.getRoom_info().getRoom_id(), SpUtil.getUserId());
|
||||
AgoraManagerEx.getInstance().leaveChannelEx(roomInfoRespPk.getRoom_info().getRoom_id(), SpUtil.getUserId());
|
||||
}
|
||||
MvpPre.postRoomInfo(roomId, "0", 2);
|
||||
mBinding.imStart2.setVisibility(GONE);
|
||||
@@ -1428,8 +1430,13 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
}
|
||||
releaseCountDownTimer();
|
||||
|
||||
var rootContainer = WheatLayoutSingManager.Companion.getInstance().getRootContainer();
|
||||
flexboxLayout.removeView(rootContainer);
|
||||
// 添加空值检查
|
||||
if (flexboxLayout != null) {
|
||||
var rootContainer = WheatLayoutSingManager.Companion.getInstance().getRootContainer();
|
||||
if (flexboxLayout.indexOfChild(rootContainer) >= 0) {
|
||||
flexboxLayout.removeView(rootContainer);
|
||||
}
|
||||
}
|
||||
|
||||
if (wheatLayoutManager1 != null) {
|
||||
wheatLayoutManager1.clear();
|
||||
@@ -1437,12 +1444,20 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
|
||||
if (wheatLayoutManager2 != null) {
|
||||
wheatLayoutManager2.clear();
|
||||
}
|
||||
mBinding.flexboxLayout.removeAllViews();
|
||||
mBinding.flexboxLayout2.removeAllViews();
|
||||
|
||||
// 添加对 mBinding 的空值检查
|
||||
if (mBinding != null) {
|
||||
if (mBinding.flexboxLayout != null) {
|
||||
mBinding.flexboxLayout.removeAllViews();
|
||||
}
|
||||
if (mBinding.flexboxLayout2 != null) {
|
||||
mBinding.flexboxLayout2.removeAllViews();
|
||||
}
|
||||
}
|
||||
|
||||
if (MvpPre != null) {
|
||||
MvpPre.detachView();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresente
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getBanners();
|
||||
MvpPre.getBanners("3");
|
||||
MvpPre.getCarousels(1, 1, "10", "2", "");//顶部推荐
|
||||
MvpPre.getCategories();
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class HotListPresenter extends BasePresenter<HotListContacts.View> implem
|
||||
LogUtils.e("token",token);
|
||||
LogUtils.e("roomId:",roomId);
|
||||
// 初始化 Agora 并加入房间
|
||||
AgoraManager.getInstance(getView().getSelfActivity())
|
||||
AgoraManager.getInstance()
|
||||
.joinRoom(token, roomId, uid, enableMic,enableJs);
|
||||
// 2. 加入房间
|
||||
// rtcCore.joinRoom(token, roomId, uid, enableMic);
|
||||
|
||||
@@ -58,10 +58,10 @@ public class RoomPresenter extends BasePresenter<RoomContacts.View> implements R
|
||||
LogUtils.e("roomId:",roomId);
|
||||
|
||||
if (getView()!= null && getView().getSelfActivity()!=null){
|
||||
AgoraManager.getInstance(getView().getSelfActivity())
|
||||
AgoraManager.getInstance()
|
||||
.joinRoom(token, roomId, uid, enableMic,enableJs);
|
||||
}else {
|
||||
AgoraManager.getInstance(mContext.getApplicationContext())
|
||||
AgoraManager.getInstance()
|
||||
.joinRoom(token, roomId, uid, enableMic,enableJs);
|
||||
}
|
||||
if (MvpRef==null){
|
||||
|
||||
@@ -55,11 +55,11 @@ public class VoiceCategoryPresenter extends BasePresenter<VoiceCategoryContacts.
|
||||
public void getMediaRoom(String label_id) {
|
||||
}
|
||||
|
||||
public void getBanners() {
|
||||
public void getBanners(String s) {
|
||||
// Type listType = new TypeToken<List<BannerModel>>() {}.getType();
|
||||
// List<BannerModel> restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtils.getHomeBanner(), listType);
|
||||
// MvpRef.get().setBanners(restoredRoomModels);
|
||||
api.getBanners(new BaseObserver<List<BannerModel>>() {
|
||||
api.getBanners(s,new BaseObserver<List<BannerModel>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
@@ -74,9 +74,8 @@ public class VoiceCategoryPresenter extends BasePresenter<VoiceCategoryContacts.
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCarousels(int type, int page, String page_limit, String is_top, String label_id) {
|
||||
if (type == 1) {//这是获取顶部的推荐房间
|
||||
|
||||
Reference in New Issue
Block a user