Handle message rerponse already in baresip service
This commit is contained in:
@ -960,11 +960,25 @@ class BaresipService: Service() {
|
||||
@Suppress("UNUSED")
|
||||
fun messageResponse(responseCode: Int, responseReason: String, time: String) {
|
||||
Log.d(TAG, "Message response '$responseCode $responseReason' at $time")
|
||||
val intent = Intent("message response")
|
||||
intent.putExtra("response code", responseCode)
|
||||
intent.putExtra("response reason", responseReason)
|
||||
intent.putExtra("time", time)
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
||||
val timeStamp = time.toLong()
|
||||
for (m in messages.reversed())
|
||||
if (m.timeStamp == timeStamp) {
|
||||
if (responseCode < 300) {
|
||||
m.direction = R.drawable.arrow_up_green
|
||||
} else {
|
||||
m.direction = R.drawable.arrow_up_red
|
||||
m.responseCode = responseCode
|
||||
m.responseReason = responseReason
|
||||
}
|
||||
break
|
||||
}
|
||||
if (Utils.isVisible()) {
|
||||
val intent = Intent("message response")
|
||||
intent.putExtra("response code", responseCode)
|
||||
intent.putExtra("response reason", responseReason)
|
||||
intent.putExtra("time", time)
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
|
||||
@ -161,9 +161,7 @@ class ChatActivity : AppCompatActivity() {
|
||||
|
||||
messageResponseReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
handleMessageResponse(intent.getIntExtra("response code", 0),
|
||||
intent.getStringExtra("response reason")!!,
|
||||
intent.getStringExtra("time")!!)
|
||||
mlAdapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,20 +272,4 @@ class ChatActivity : AppCompatActivity() {
|
||||
return res
|
||||
}
|
||||
|
||||
private fun handleMessageResponse(responseCode: Int, responseReason: String, time: String) {
|
||||
val timeStamp = time.toLong()
|
||||
for (m in chatMessages.reversed())
|
||||
if (m.timeStamp == timeStamp) {
|
||||
if (responseCode < 300) {
|
||||
m.direction = R.drawable.arrow_up_green
|
||||
} else {
|
||||
m.direction = R.drawable.arrow_up_red
|
||||
m.responseCode = responseCode
|
||||
m.responseReason = responseReason
|
||||
}
|
||||
mlAdapter.notifyDataSetChanged()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user