Catch exception when posting a navigation task on main thread

This commit is contained in:
Sylvain Berfini 2024-08-21 10:35:31 +02:00
parent ab1ea3392d
commit 674fa1f41b
5 changed files with 26 additions and 8 deletions

View file

@ -93,8 +93,12 @@ class AssistantActivity : GenericActivity() {
coreContext.postOnCoreThread { core ->
if (core.accountList.isNotEmpty()) {
coreContext.postOnMainThread {
Log.w("$TAG At least one account was found, leaving assistant")
finish()
try {
Log.w("$TAG At least one account was found, leaving assistant")
finish()
} catch (ise: IllegalStateException) {
Log.e("$TAG Can't finish activity: $ise")
}
}
}
}

View file

@ -42,7 +42,11 @@ class NewCallFragment : AbstractNewTransferCallFragment() {
coreContext.startAudioCall(address)
coreContext.postOnMainThread {
findNavController().popBackStack()
try {
findNavController().popBackStack()
} catch (ise: IllegalStateException) {
Log.e("$TAG Can't go back: $ise")
}
}
}
}

View file

@ -56,7 +56,11 @@ class TransferCallFragment : AbstractNewTransferCallFragment() {
callViewModel.blindTransferCallTo(address)
coreContext.postOnMainThread {
findNavController().popBackStack()
try {
findNavController().popBackStack()
} catch (ise: IllegalStateException) {
Log.e("$TAG Can't go back: $ise")
}
}
}
}

View file

@ -509,12 +509,20 @@ class MainActivity : GenericActivity() {
Log.i("$TAG First time Linphone 6.0 has been started, showing Welcome activity")
corePreferences.firstLaunch = false
coreContext.postOnMainThread {
startActivity(Intent(this, WelcomeActivity::class.java))
try {
startActivity(Intent(this, WelcomeActivity::class.java))
} catch (ise: IllegalStateException) {
Log.e("$TAG Can't start activity: $ise")
}
}
} else if (core.accountList.isEmpty()) {
Log.w("$TAG No account found, showing Assistant activity")
coreContext.postOnMainThread {
startActivity(Intent(this, AssistantActivity::class.java))
try {
startActivity(Intent(this, AssistantActivity::class.java))
} catch (ise: IllegalStateException) {
Log.e("$TAG Can't start activity: $ise")
}
}
} else {
if (intent.hasExtra("Chat")) {

View file

@ -170,8 +170,6 @@ class ConversationForwardMessageViewModel @UiThread constructor() : AddressSelec
)
showNumberOrAddressPickerDialogEvent.postValue(Event(list))
coreContext.postOnMainThread {
}
}
}
}