From f6c9df00de1ac492c9d168a3208bac3a8c1c0443 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 25 Oct 2023 09:40:25 +0200 Subject: [PATCH] run account deletion callback on ui thread --- .../siacs/conversations/ui/XmppActivity.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index c6a6bc630..cebb8c22f 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -317,22 +317,24 @@ public abstract class XmppActivity extends ActionBarActivity { button.setText(R.string.please_wait); button.setEnabled(false); xmppConnectionService.unregisterAccount(account, result -> { - if (result) { - dialog.dismiss(); - if (postDelete != null) { - postDelete.run(); + runOnUiThread(()->{ + if (result) { + dialog.dismiss(); + if (postDelete != null) { + postDelete.run(); + } + if (xmppConnectionService.getAccounts().size() == 0 && Config.MAGIC_CREATE_DOMAIN != null) { + final Intent intent = SignupUtils.getSignUpIntent(this); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + startActivity(intent); + } + } else { + deleteFromServer.setEnabled(true); + button.setText(R.string.delete); + button.setEnabled(true); + Toast.makeText(this,R.string.could_not_delete_account_from_server,Toast.LENGTH_LONG).show(); } - if (xmppConnectionService.getAccounts().size() == 0 && Config.MAGIC_CREATE_DOMAIN != null) { - final Intent intent = SignupUtils.getSignUpIntent(this); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); - startActivity(intent); - } - } else { - deleteFromServer.setEnabled(true); - button.setText(R.string.delete); - button.setEnabled(true); - Toast.makeText(this,R.string.could_not_delete_account_from_server,Toast.LENGTH_LONG).show(); - } + }); }); } else { Toast.makeText(this,R.string.not_connected_try_again,Toast.LENGTH_LONG).show();