优化roomBtnShowIsHide
This commit is contained in:
@@ -192,6 +192,7 @@ import java.lang.ref.WeakReference
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.util.Arrays
|
||||
import java.util.Date
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.stream.Collectors
|
||||
|
||||
@@ -1597,13 +1598,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
//TODO================ CP入场不触发播放 临时添加===============
|
||||
Observable.timer(1000, TimeUnit.MILLISECONDS).observeOn(
|
||||
AndroidSchedulers.mainThread()
|
||||
).subscribe { aLong: Long? ->
|
||||
if (ActivityUtils.getTopActivity() is RoomActivity) {
|
||||
toActivity(TransparentActivity::class.java)
|
||||
}
|
||||
}
|
||||
scheduleEnterActivityOnce()
|
||||
} else if (msgType == EMMessageInfo.QXRoomMessageTypeSignStartText) {
|
||||
roomFragment?.handleRoomMessage(messageEvent)
|
||||
softRebuildUI()
|
||||
@@ -2130,13 +2125,8 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
//TODO================ 坐骑入场不触发播放 临时添加===============
|
||||
Observable.timer(1000, TimeUnit.MILLISECONDS).observeOn(
|
||||
AndroidSchedulers.mainThread()
|
||||
).subscribe { aLong: Long? ->
|
||||
if (ActivityUtils.getTopActivity() is RoomActivity) {
|
||||
toActivity(TransparentActivity::class.java)
|
||||
}
|
||||
}
|
||||
scheduleEnterActivityOnce()
|
||||
|
||||
MvpPre?.getRoomOnline(roomId, "1", "10")
|
||||
|
||||
// number++
|
||||
@@ -3026,6 +3016,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
|
||||
private var currentMicState: Int = -1 // -1 未知,1 开,2 关
|
||||
private val micExecutor = Executors.newSingleThreadExecutor()
|
||||
/**
|
||||
* 设置是否打开麦克风
|
||||
*
|
||||
@@ -3033,22 +3026,45 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
*/
|
||||
fun switchMic(type: Int) {
|
||||
logIn("switchMic-${type}-")
|
||||
// ====== 1. 状态去重(非常关键) ======
|
||||
if (currentMicState == type) {
|
||||
return
|
||||
}
|
||||
currentMicState = type
|
||||
|
||||
// ====== 2. UI 只做 UI ======
|
||||
if (type == 1) {
|
||||
mBinding!!.ivMic.setImageResource(com.xscm.moduleutil.R.mipmap.room_microphone)
|
||||
AgoraManager.getInstance()
|
||||
.setLocalAudioEnabled(true, SpUtil.getUserId().toString() + "")
|
||||
isSwith = false
|
||||
AgoraManager.getInstance().muteLocalAudioStream(false)
|
||||
AgoraManager.getInstance().ClientRole(true)
|
||||
mBinding?.ivMic?.setImageResource(
|
||||
com.xscm.moduleutil.R.mipmap.room_microphone
|
||||
)
|
||||
CommonAppContext.getInstance().isMai = true
|
||||
} else {
|
||||
mBinding!!.ivMic.setImageResource(com.xscm.moduleutil.R.mipmap.room_microphone_off)
|
||||
AgoraManager.getInstance()
|
||||
.setLocalAudioEnabled(false, SpUtil.getUserId().toString() + "")
|
||||
isSwith = true
|
||||
isMute(1)
|
||||
mBinding?.ivMic?.setImageResource(
|
||||
com.xscm.moduleutil.R.mipmap.room_microphone_off
|
||||
)
|
||||
CommonAppContext.getInstance().isMai = false
|
||||
}
|
||||
|
||||
// ====== 3. SDK 调用全部丢到后台线程 ======
|
||||
micExecutor.execute {
|
||||
try {
|
||||
val agora = AgoraManager.getInstance()
|
||||
val uid = SpUtil.getUserId().toString()
|
||||
|
||||
if (type == 1) {
|
||||
agora.setLocalAudioEnabled(true, uid)
|
||||
agora.muteLocalAudioStream(false)
|
||||
agora.ClientRole(true)
|
||||
isSwith = false
|
||||
} else {
|
||||
agora.setLocalAudioEnabled(false, uid)
|
||||
isMute(1)
|
||||
isSwith = true
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setPrivateRoomShowBottom() {
|
||||
@@ -3198,18 +3214,24 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
mBinding?.ivSoundEffects?.visibility = View.GONE
|
||||
mBinding?.rlPk?.visibility = View.GONE
|
||||
}
|
||||
requestLayout(mBinding!!.rlPk)
|
||||
requestLayout(mBinding!!.rlMai)
|
||||
|
||||
|
||||
//TODO================ CP入场不触发播放 临时添加===============
|
||||
Observable.timer(1000, TimeUnit.MILLISECONDS).observeOn(
|
||||
AndroidSchedulers.mainThread()
|
||||
).subscribe { aLong: Long? ->
|
||||
if (ActivityUtils.getTopActivity() is RoomActivity) {
|
||||
toActivity(TransparentActivity::class.java)
|
||||
}
|
||||
scheduleEnterActivityOnce()
|
||||
}
|
||||
|
||||
private var enterTimerDisposable: Disposable? = null
|
||||
private fun scheduleEnterActivityOnce() {
|
||||
if (enterTimerDisposable != null && !enterTimerDisposable!!.isDisposed) {
|
||||
return
|
||||
}
|
||||
enterTimerDisposable = Observable
|
||||
.timer(1, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
if (!isFinishing && ActivityUtils.getTopActivity() is RoomActivity) {
|
||||
toActivity(TransparentActivity::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3583,13 +3605,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
QXGiftPlayerManager.getInstance(this).displayFullEffectView(event.ride_url)
|
||||
}
|
||||
//TODO================ 坐骑入场不触发播放 临时添加===============
|
||||
Observable.timer(1000, TimeUnit.MILLISECONDS).observeOn(
|
||||
AndroidSchedulers.mainThread()
|
||||
).subscribe { aLong: Long? ->
|
||||
if (ActivityUtils.getTopActivity() is RoomActivity) {
|
||||
toActivity(TransparentActivity::class.java)
|
||||
}
|
||||
}
|
||||
scheduleEnterActivityOnce()
|
||||
}
|
||||
|
||||
is RoomWheatEvent -> {
|
||||
|
||||
Reference in New Issue
Block a user