84 师徒任务添加容错

This commit is contained in:
2025-12-12 11:40:44 +08:00
parent 89374e536d
commit 17b562f194
2 changed files with 49 additions and 28 deletions

View File

@@ -2,6 +2,7 @@ package com.xscm.modulemain
import android.app.Activity
import android.content.Context
import android.text.TextUtils
import android.view.View
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.AppUtils
@@ -39,7 +40,7 @@ open class Application : CommonAppContext() {
var isAgoraStop = false
var inviteDialog: InviteDialog? = null
var currDialogActivity:Activity? = null
var currDialogActivity: Activity? = null
// 单例实例
companion object {
@@ -85,34 +86,44 @@ open class Application : CommonAppContext() {
when (event.msgType) {
CustomMsgCode.CODE_TASK_APPRENTICE_JOIN_ROOM -> {
TimerManager.cancelTimer(CustomMsgCode.CODE_TASK_APPRENTICE_JOIN_ROOM_TIMER_ID)
val json = JSONObject(event.text.text)
event.text.status = json.getString("status")
when (event.text.status) {
"1" -> {//1:邀请
event.text.room_id = json.getString("room_id")
if (event?.text?.room_id.isNullOrEmpty())
return@setOnMsgTaskListener
customDialog(
event.text.room_id,
CustomMsgCode.CODE_TASK_APPRENTICE_JOIN_ROOM_MSG,
5,
1,
event.text
)
try {
val json = JSONObject(event.text.text)
if (!json.isNull("status")) {
event.text.status = json.getString("status")
}
if (TextUtils.isEmpty(event.text.status))
return@setOnMsgTaskListener
when (event.text.status) {
"1" -> {//1:邀请
if (!json.isNull("room_id"))
event.text.room_id = json.getString("room_id")
if (event?.text?.room_id.isNullOrEmpty())
return@setOnMsgTaskListener
customDialog(
event.text.room_id,
CustomMsgCode.CODE_TASK_APPRENTICE_JOIN_ROOM_MSG,
5,
1,
event.text
)
}
"2" -> {//2:拒绝
customDialog(
"",
CustomMsgCode.CODE_TASK_APPRENTICE_JOIN_ROOM_MSG_REFUSE,
5,
3,
null,
"",
"知道了"
)
"2" -> {//2:拒绝
customDialog(
"",
CustomMsgCode.CODE_TASK_APPRENTICE_JOIN_ROOM_MSG_REFUSE,
5,
3,
null,
"",
"知道了"
)
}
}
}catch (E: Exception){
LogUtils.e("Exception",E.message.toString())
}
}
}
}
@@ -137,10 +148,14 @@ open class Application : CommonAppContext() {
{ v: View? ->
when (status) {
1 -> {
if (roomId == CommonAppContext.getInstance().playId)
if (!TextUtils.isEmpty(CommonAppContext.getInstance().playId)
&& roomId == CommonAppContext.getInstance().playId
&& ActivityUtils.getTopActivity() is RoomActivity
) {
return@ConfirmDialog
}
if (ActivityUtils.getTopActivity() is RoomActivity){
if (ActivityUtils.getTopActivity() is RoomActivity) {
(ActivityUtils.getTopActivity() as RoomActivity).refreshRoomInfo(roomId)
return@ConfirmDialog
}
@@ -172,7 +187,7 @@ open class Application : CommonAppContext() {
fun inviteApprenticeTaskTimer() {
TimerManager.scheduleTimer(
CustomMsgCode.CODE_TASK_APPRENTICE_JOIN_ROOM_TIMER_ID,
15,
20,
TimeUnit.SECONDS,
onTimeUp = {
customDialog(