From c7ce5265854c0f71d3b4621872c5be1a437809eb Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Fri, 8 May 2020 10:12:25 +0300 Subject: [PATCH] - Added UserAgent add, remove, and updateStatus methods. --- .../com/tutpro/baresip/AccountActivity.kt | 4 +-- .../com/tutpro/baresip/AccountListAdapter.kt | 2 +- .../com/tutpro/baresip/AccountsActivity.kt | 2 +- .../kotlin/com/tutpro/baresip/UserAgent.kt | 35 ++++++++----------- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt index 7c5263a0..55c40b3b 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt @@ -323,12 +323,12 @@ class AccountActivity : AppCompatActivity() { if (regCheck.isChecked) { if (acc.regint != 3600) { newRegint = 3600 - UserAgent.updateStatus(ua, R.drawable.dot_yellow) + ua.updateStatus(R.drawable.dot_yellow) } } else { if (acc.regint != 0) { Api.ua_unregister(ua.uap) - UserAgent.updateStatus(ua, R.drawable.dot_white) + ua.updateStatus(R.drawable.dot_white) newRegint = 0 } } diff --git a/app/src/main/kotlin/com/tutpro/baresip/AccountListAdapter.kt b/app/src/main/kotlin/com/tutpro/baresip/AccountListAdapter.kt index 5af4e4f8..dc5e7863 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AccountListAdapter.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AccountListAdapter.kt @@ -45,7 +45,7 @@ class AccountListAdapter(private val cxt: Context, private val rows: ArrayList { @@ -15,26 +30,6 @@ class UserAgent(val uap: String) { return BaresipService.status } - fun add(ua: UserAgent, status: Int) { - BaresipService.uas.add(ua) - BaresipService.status.add(status) - } - - fun remove(ua: UserAgent) { - val index = BaresipService.uas.indexOf(ua) - if (index != -1) { - BaresipService.uas.removeAt(index) - BaresipService.status.removeAt(index) - } - } - - fun updateStatus(ua: UserAgent, status: Int) { - val index = BaresipService.uas.indexOf(ua) - if (index != -1) { - BaresipService.status[index] = status - } - } - fun ofAor(aor: String): UserAgent? { for (ua in BaresipService.uas) if (ua.account.aor == aor) return ua