feat: add currentTempGroupId caching and start/end lock JS callbacks in TempCallActivity
This commit is contained in:
parent
bfa19d36ac
commit
38c7494d73
|
|
@ -42,6 +42,9 @@ class TempCallActivity : AppCompatActivity() {
|
|||
@Volatile
|
||||
var currentGroupName: String = "临时会话"
|
||||
|
||||
@Volatile
|
||||
var currentTempGroupId: String = ""
|
||||
|
||||
@JvmStatic
|
||||
fun isOpen(): Boolean = instance != null
|
||||
|
||||
|
|
@ -78,7 +81,9 @@ class TempCallActivity : AppCompatActivity() {
|
|||
fun clearMinimizedState() {
|
||||
isMinimized = false
|
||||
currentGroupName = "临时会话"
|
||||
currentTempGroupId = ""
|
||||
MainActivity.executeJs("onTempCallStateChanged('destroyed')")
|
||||
MainActivity.executeJs("if(window.endPullGroupLock){ window.endPullGroupLock(); }")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,6 +103,8 @@ class TempCallActivity : AppCompatActivity() {
|
|||
|
||||
val groupName = intent.getStringExtra("group_name") ?: "临时会话"
|
||||
currentGroupName = groupName
|
||||
currentTempGroupId = com.example.kingway.ptt.SendAtUtil.str2HexStr(groupName)
|
||||
MainActivity.executeJs("if(window.startPullGroupLock){ window.startPullGroupLock('$currentTempGroupId'); }")
|
||||
findViewById<TextView>(R.id.tv_group_name).text = groupName
|
||||
|
||||
setupMinimizeButton()
|
||||
|
|
@ -105,6 +112,7 @@ class TempCallActivity : AppCompatActivity() {
|
|||
setupHangupButton()
|
||||
startPulseAnimation()
|
||||
startVoiceAlert()
|
||||
fetchPullRecord()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
@ -119,8 +127,12 @@ class TempCallActivity : AppCompatActivity() {
|
|||
instance = null
|
||||
if (!isMinimized) {
|
||||
currentGroupName = "临时会话"
|
||||
currentTempGroupId = ""
|
||||
}
|
||||
MainActivity.executeJs("onTempCallStateChanged('" + if (isMinimized) "minimized" else "destroyed" + "')")
|
||||
if (!isMinimized) {
|
||||
MainActivity.executeJs("if(window.endPullGroupLock){ window.endPullGroupLock(); }")
|
||||
}
|
||||
}
|
||||
stopVoiceAlert()
|
||||
}
|
||||
|
|
@ -331,4 +343,52 @@ class TempCallActivity : AppCompatActivity() {
|
|||
alertPlayer = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchPullRecord() {
|
||||
val serverUrl = AppConfig.getServerUrl(this)
|
||||
val token = AppConfig.getAccessToken(this)
|
||||
if (token.isEmpty()) {
|
||||
Timber.tag("TempCallAlert").w("AccessToken is empty, cannot query pull record")
|
||||
return
|
||||
}
|
||||
|
||||
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("TempCallAlert").e(e, "获取拉动记录失败")
|
||||
}
|
||||
|
||||
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")
|
||||
if (dataArray != null && dataArray.length() > 0) {
|
||||
val record = dataArray.optJSONObject(0) ?: return
|
||||
val pullTitle = record.optString("pullTitle", "")
|
||||
val pullTime = record.optString("pullTime", "")
|
||||
val sourceUnitName = record.optString("sourceUnitName", "")
|
||||
|
||||
runOnUiThread {
|
||||
findViewById<View>(R.id.ll_pull_info)?.visibility = View.VISIBLE
|
||||
findViewById<TextView>(R.id.tv_pull_title)?.text = "标题:$pullTitle"
|
||||
findViewById<TextView>(R.id.tv_pull_source_unit)?.text = "发送单位:$sourceUnitName"
|
||||
findViewById<TextView>(R.id.tv_pull_time)?.text = "拉动时间:$pullTime"
|
||||
findViewById<TextView>(R.id.tv_pull_content)?.text = "内容:请注意!正在对你单位进行视频拉动。"
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.tag("TempCallAlert").e(e, "解析拉动记录响应失败")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue