优化roomBtnShowIsHide
This commit is contained in:
@@ -192,6 +192,7 @@ import java.lang.ref.WeakReference
|
|||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.util.Arrays
|
import java.util.Arrays
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import java.util.stream.Collectors
|
import java.util.stream.Collectors
|
||||||
|
|
||||||
@@ -1597,13 +1598,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO================ CP入场不触发播放 临时添加===============
|
//TODO================ CP入场不触发播放 临时添加===============
|
||||||
Observable.timer(1000, TimeUnit.MILLISECONDS).observeOn(
|
scheduleEnterActivityOnce()
|
||||||
AndroidSchedulers.mainThread()
|
|
||||||
).subscribe { aLong: Long? ->
|
|
||||||
if (ActivityUtils.getTopActivity() is RoomActivity) {
|
|
||||||
toActivity(TransparentActivity::class.java)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (msgType == EMMessageInfo.QXRoomMessageTypeSignStartText) {
|
} else if (msgType == EMMessageInfo.QXRoomMessageTypeSignStartText) {
|
||||||
roomFragment?.handleRoomMessage(messageEvent)
|
roomFragment?.handleRoomMessage(messageEvent)
|
||||||
softRebuildUI()
|
softRebuildUI()
|
||||||
@@ -2130,13 +2125,8 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO================ 坐骑入场不触发播放 临时添加===============
|
//TODO================ 坐骑入场不触发播放 临时添加===============
|
||||||
Observable.timer(1000, TimeUnit.MILLISECONDS).observeOn(
|
scheduleEnterActivityOnce()
|
||||||
AndroidSchedulers.mainThread()
|
|
||||||
).subscribe { aLong: Long? ->
|
|
||||||
if (ActivityUtils.getTopActivity() is RoomActivity) {
|
|
||||||
toActivity(TransparentActivity::class.java)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MvpPre?.getRoomOnline(roomId, "1", "10")
|
MvpPre?.getRoomOnline(roomId, "1", "10")
|
||||||
|
|
||||||
// number++
|
// number++
|
||||||
@@ -3026,6 +3016,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
dialog.show()
|
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) {
|
fun switchMic(type: Int) {
|
||||||
logIn("switchMic-${type}-")
|
logIn("switchMic-${type}-")
|
||||||
|
// ====== 1. 状态去重(非常关键) ======
|
||||||
|
if (currentMicState == type) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currentMicState = type
|
||||||
|
|
||||||
|
// ====== 2. UI 只做 UI ======
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
mBinding!!.ivMic.setImageResource(com.xscm.moduleutil.R.mipmap.room_microphone)
|
mBinding?.ivMic?.setImageResource(
|
||||||
AgoraManager.getInstance()
|
com.xscm.moduleutil.R.mipmap.room_microphone
|
||||||
.setLocalAudioEnabled(true, SpUtil.getUserId().toString() + "")
|
)
|
||||||
isSwith = false
|
|
||||||
AgoraManager.getInstance().muteLocalAudioStream(false)
|
|
||||||
AgoraManager.getInstance().ClientRole(true)
|
|
||||||
CommonAppContext.getInstance().isMai = true
|
CommonAppContext.getInstance().isMai = true
|
||||||
} else {
|
} else {
|
||||||
mBinding!!.ivMic.setImageResource(com.xscm.moduleutil.R.mipmap.room_microphone_off)
|
mBinding?.ivMic?.setImageResource(
|
||||||
AgoraManager.getInstance()
|
com.xscm.moduleutil.R.mipmap.room_microphone_off
|
||||||
.setLocalAudioEnabled(false, SpUtil.getUserId().toString() + "")
|
)
|
||||||
isSwith = true
|
|
||||||
isMute(1)
|
|
||||||
CommonAppContext.getInstance().isMai = false
|
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() {
|
fun setPrivateRoomShowBottom() {
|
||||||
@@ -3198,18 +3214,24 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
mBinding?.ivSoundEffects?.visibility = View.GONE
|
mBinding?.ivSoundEffects?.visibility = View.GONE
|
||||||
mBinding?.rlPk?.visibility = View.GONE
|
mBinding?.rlPk?.visibility = View.GONE
|
||||||
}
|
}
|
||||||
requestLayout(mBinding!!.rlPk)
|
|
||||||
requestLayout(mBinding!!.rlMai)
|
|
||||||
|
|
||||||
|
|
||||||
//TODO================ CP入场不触发播放 临时添加===============
|
//TODO================ CP入场不触发播放 临时添加===============
|
||||||
Observable.timer(1000, TimeUnit.MILLISECONDS).observeOn(
|
scheduleEnterActivityOnce()
|
||||||
AndroidSchedulers.mainThread()
|
}
|
||||||
).subscribe { aLong: Long? ->
|
|
||||||
if (ActivityUtils.getTopActivity() is RoomActivity) {
|
private var enterTimerDisposable: Disposable? = null
|
||||||
toActivity(TransparentActivity::class.java)
|
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)
|
QXGiftPlayerManager.getInstance(this).displayFullEffectView(event.ride_url)
|
||||||
}
|
}
|
||||||
//TODO================ 坐骑入场不触发播放 临时添加===============
|
//TODO================ 坐骑入场不触发播放 临时添加===============
|
||||||
Observable.timer(1000, TimeUnit.MILLISECONDS).observeOn(
|
scheduleEnterActivityOnce()
|
||||||
AndroidSchedulers.mainThread()
|
|
||||||
).subscribe { aLong: Long? ->
|
|
||||||
if (ActivityUtils.getTopActivity() is RoomActivity) {
|
|
||||||
toActivity(TransparentActivity::class.java)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is RoomWheatEvent -> {
|
is RoomWheatEvent -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user