临时群调整
This commit is contained in:
parent
f7def3a7f6
commit
d570ecb57f
|
|
@ -277,26 +277,29 @@ public class CallBackResolution {
|
|||
|
||||
// 处理临时呼叫页面逻辑
|
||||
if (code == 1) {
|
||||
try {
|
||||
android.content.Context context = com.stand.standapp.MyApplication.getAppInstance();
|
||||
String account = com.stand.standapp.AppConfig.getSavedUsername(context);
|
||||
String token = com.stand.standapp.AppConfig.getAccessToken(context);
|
||||
String tempGroupName = "临时会话";
|
||||
if (tempTxt.startsWith("临时呼叫") && tempTxt.length() > "临时呼叫".length()) {
|
||||
tempGroupName = tempTxt.substring("临时呼叫".length());
|
||||
}
|
||||
com.stand.standapp.TempCallActivity.checkAndHandleTempGroup(context, account, token, tempGroupName);
|
||||
} catch (Exception e) {
|
||||
Timber.tag(TAG).e(e, "Failed to check initiator status and handle TempCallActivity");
|
||||
}
|
||||
com.stand.standapp.MainActivity.executeJs("onTempCallStateChanged('created')");
|
||||
// try {
|
||||
// android.content.Context context = com.stand.standapp.MyApplication.getAppInstance();
|
||||
// String account = com.stand.standapp.AppConfig.getSavedUsername(context);
|
||||
// String token = com.stand.standapp.AppConfig.getAccessToken(context);
|
||||
// String tempGroupName = "临时会话";
|
||||
// if (tempTxt.startsWith("临时呼叫") && tempTxt.length() > "临时呼叫".length()) {
|
||||
// tempGroupName = tempTxt.substring("临时呼叫".length());
|
||||
// }
|
||||
// com.stand.standapp.TempCallActivity.checkAndHandleTempGroup(context, account, token, tempGroupName);
|
||||
// } catch (Exception e) {
|
||||
// Timber.tag(TAG).e(e, "Failed to check initiator status and handle TempCallActivity");
|
||||
// }
|
||||
} else if (code == 0) {
|
||||
// 退出临时呼叫 → 关闭临时呼叫页面
|
||||
if (com.stand.standapp.TempCallActivity.isOpen()) {
|
||||
com.stand.standapp.TempCallActivity.closeWithMessage("临时呼叫已结束");
|
||||
} else if (com.stand.standapp.TempCallActivity.isMinimizedState()) {
|
||||
// 最小化状态下收到结束消息,清除状态并通知前端
|
||||
com.stand.standapp.TempCallActivity.clearMinimizedState();
|
||||
}
|
||||
com.stand.standapp.MainActivity.executeJs("onTempCallStateChanged('destroyed')");
|
||||
com.stand.standapp.MainActivity.executeJs("if(window.endPullGroupLock){ window.endPullGroupLock(); }");
|
||||
// if (com.stand.standapp.TempCallActivity.isOpen()) {
|
||||
// com.stand.standapp.TempCallActivity.closeWithMessage("临时呼叫已结束");
|
||||
// } else if (com.stand.standapp.TempCallActivity.isMinimizedState()) {
|
||||
// // 最小化状态下收到结束消息,清除状态并通知前端
|
||||
// com.stand.standapp.TempCallActivity.clearMinimizedState();
|
||||
// }
|
||||
} else if (code == 2) {
|
||||
// 呼叫失败 → 关闭临时呼叫页面
|
||||
// if (com.stand.standapp.TempCallActivity.isOpen()) {
|
||||
|
|
|
|||
|
|
@ -97,105 +97,105 @@ class TempCallActivity : AppCompatActivity() {
|
|||
groupNameFromCall: String? = null,
|
||||
targetGid: String? = null
|
||||
) {
|
||||
if (token.isEmpty()) {
|
||||
Timber.tag("TempGroupCheck").w("token is empty, skip check")
|
||||
return
|
||||
}
|
||||
|
||||
val serverUrl = AppConfig.getServerUrl(context)
|
||||
val url = "$serverUrl/api/vid-pull-record/my-list"
|
||||
|
||||
val request = okhttp3.Request.Builder()
|
||||
.url(url)
|
||||
.addHeader("Authorization", "Bearer $token")
|
||||
.get()
|
||||
.build()
|
||||
|
||||
com.stand.standapp.net.NetworkModule.defaultClient.newCall(request).enqueue(object : okhttp3.Callback {
|
||||
override fun onFailure(call: okhttp3.Call, e: java.io.IOException) {
|
||||
Timber.tag("TempGroupCheck").e(e, "获取拉动记录失败")
|
||||
if (groupNameFromCall != null) {
|
||||
startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResponse(call: okhttp3.Call, response: okhttp3.Response) {
|
||||
try {
|
||||
val body = response.body?.string() ?: return
|
||||
val json = org.json.JSONObject(body)
|
||||
if (json.optInt("code", -1) == 0) {
|
||||
val dataArray = json.optJSONArray("data")
|
||||
var matchedRecord: org.json.JSONObject? = null
|
||||
|
||||
if (dataArray != null && dataArray.length() > 0) {
|
||||
// 1. 如果指定了 GID,优先按 GID 匹配
|
||||
if (targetGid != null && targetGid.isNotEmpty()) {
|
||||
for (i in 0 until dataArray.length()) {
|
||||
val record = dataArray.optJSONObject(i) ?: continue
|
||||
val pocGid = record.optString("pocGid", "")
|
||||
if (pocGid == targetGid) {
|
||||
matchedRecord = record
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 如果未指定 GID 或未匹配到,且有传入的呼叫群组名称,按名称匹配
|
||||
if (matchedRecord == null && groupNameFromCall != null && groupNameFromCall.isNotEmpty() && groupNameFromCall != "临时会话") {
|
||||
for (i in 0 until dataArray.length()) {
|
||||
val record = dataArray.optJSONObject(i) ?: continue
|
||||
val pullTitle = record.optString("pullTitle", "")
|
||||
if (pullTitle.contains(groupNameFromCall) || groupNameFromCall.contains(pullTitle)) {
|
||||
matchedRecord = record
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 如果仍未匹配到,默认使用最新的一条记录
|
||||
if (matchedRecord == null) {
|
||||
matchedRecord = dataArray.optJSONObject(0)
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedRecord != null) {
|
||||
val pocGid = matchedRecord.optString("pocGid", "")
|
||||
val pullTitle = matchedRecord.optString("pullTitle", "临时会话")
|
||||
val createBy = matchedRecord.optString("createBy", "")
|
||||
val currentUserId = AppConfig.getSavedUserId(context)
|
||||
|
||||
val isInitiator = currentUserId.isNotEmpty() && currentUserId == createBy
|
||||
Timber.tag("TempGroupCheck").d("匹配拉动记录成功: title=$pullTitle, pocGid=$pocGid, createBy=$createBy, isInitiator=$isInitiator")
|
||||
|
||||
if (isInitiator) {
|
||||
isMinimized = true
|
||||
currentTempGroupId = pocGid
|
||||
currentGroupName = pullTitle
|
||||
MainActivity.executeJs("onTempCallStateChanged('minimized')")
|
||||
if (pocGid.isNotEmpty()) {
|
||||
MainActivity.executeJs("if(window.startPullGroupLock){ window.startPullGroupLock('$pocGid'); }")
|
||||
}
|
||||
} else {
|
||||
startTempCallActivity(context, pullTitle, pocGid)
|
||||
}
|
||||
} else {
|
||||
if (groupNameFromCall != null) {
|
||||
startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (groupNameFromCall != null) {
|
||||
startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("TempGroupCheck").e(e, "解析拉动记录响应失败")
|
||||
if (groupNameFromCall != null) {
|
||||
startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
// if (token.isEmpty()) {
|
||||
// Timber.tag("TempGroupCheck").w("token is empty, skip check")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// val serverUrl = AppConfig.getServerUrl(context)
|
||||
// val url = "$serverUrl/api/vid-pull-record/my-list"
|
||||
//
|
||||
// val request = okhttp3.Request.Builder()
|
||||
// .url(url)
|
||||
// .addHeader("Authorization", "Bearer $token")
|
||||
// .get()
|
||||
// .build()
|
||||
//
|
||||
// com.stand.standapp.net.NetworkModule.defaultClient.newCall(request).enqueue(object : okhttp3.Callback {
|
||||
// override fun onFailure(call: okhttp3.Call, e: java.io.IOException) {
|
||||
// Timber.tag("TempGroupCheck").e(e, "获取拉动记录失败")
|
||||
// if (groupNameFromCall != null) {
|
||||
// startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onResponse(call: okhttp3.Call, response: okhttp3.Response) {
|
||||
// try {
|
||||
// val body = response.body?.string() ?: return
|
||||
// val json = org.json.JSONObject(body)
|
||||
// if (json.optInt("code", -1) == 0) {
|
||||
// val dataArray = json.optJSONArray("data")
|
||||
// var matchedRecord: org.json.JSONObject? = null
|
||||
//
|
||||
// if (dataArray != null && dataArray.length() > 0) {
|
||||
// // 1. 如果指定了 GID,优先按 GID 匹配
|
||||
// if (targetGid != null && targetGid.isNotEmpty()) {
|
||||
// for (i in 0 until dataArray.length()) {
|
||||
// val record = dataArray.optJSONObject(i) ?: continue
|
||||
// val pocGid = record.optString("pocGid", "")
|
||||
// if (pocGid == targetGid) {
|
||||
// matchedRecord = record
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 2. 如果未指定 GID 或未匹配到,且有传入的呼叫群组名称,按名称匹配
|
||||
// if (matchedRecord == null && groupNameFromCall != null && groupNameFromCall.isNotEmpty() && groupNameFromCall != "临时会话") {
|
||||
// for (i in 0 until dataArray.length()) {
|
||||
// val record = dataArray.optJSONObject(i) ?: continue
|
||||
// val pullTitle = record.optString("pullTitle", "")
|
||||
// if (pullTitle.contains(groupNameFromCall) || groupNameFromCall.contains(pullTitle)) {
|
||||
// matchedRecord = record
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 3. 如果仍未匹配到,默认使用最新的一条记录
|
||||
// if (matchedRecord == null) {
|
||||
// matchedRecord = dataArray.optJSONObject(0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (matchedRecord != null) {
|
||||
// val pocGid = matchedRecord.optString("pocGid", "")
|
||||
// val pullTitle = matchedRecord.optString("pullTitle", "临时会话")
|
||||
// val createBy = matchedRecord.optString("createBy", "")
|
||||
// val currentUserId = AppConfig.getSavedUserId(context)
|
||||
//
|
||||
// val isInitiator = currentUserId.isNotEmpty() && currentUserId == createBy
|
||||
// Timber.tag("TempGroupCheck").d("匹配拉动记录成功: title=$pullTitle, pocGid=$pocGid, createBy=$createBy, isInitiator=$isInitiator")
|
||||
//
|
||||
// if (isInitiator) {
|
||||
// isMinimized = true
|
||||
// currentTempGroupId = pocGid
|
||||
// currentGroupName = pullTitle
|
||||
// MainActivity.executeJs("onTempCallStateChanged('minimized')")
|
||||
// if (pocGid.isNotEmpty()) {
|
||||
// MainActivity.executeJs("if(window.startPullGroupLock){ window.startPullGroupLock('$pocGid'); }")
|
||||
// }
|
||||
// } else {
|
||||
// startTempCallActivity(context, pullTitle, pocGid)
|
||||
// }
|
||||
// } else {
|
||||
// if (groupNameFromCall != null) {
|
||||
// startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// if (groupNameFromCall != null) {
|
||||
// startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
|
||||
// }
|
||||
// }
|
||||
// } catch (e: Exception) {
|
||||
// Timber.tag("TempGroupCheck").e(e, "解析拉动记录响应失败")
|
||||
// if (groupNameFromCall != null) {
|
||||
// startTempCallActivity(context, groupNameFromCall, targetGid ?: "")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
|
|
|||
Loading…
Reference in New Issue