From 9f3eeb3d0d39d1e73204ed7c759d6ff5b58c5fcb Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Tue, 12 Nov 2024 18:01:02 +0100 Subject: [PATCH] calculate account size in background calculation may take a moment, do this in background. it is totally fine to just display nothing before, that avoids flickering (WHAT was this? i cannot look so fast!) - and in most cases, it is close to instant. --- .../accounts/AccountSelectionListFragment.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListFragment.java b/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListFragment.java index 70f4f6daf..800eda81a 100644 --- a/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/accounts/AccountSelectionListFragment.java @@ -168,11 +168,16 @@ private void onDeleteAccount(int accountId) { avatar.setAvatar(GlideApp.with(activity), recipient, false); nameView.setText(name); addrView.setText(contact.getAddr()); - try { - sizeView.setText(Util.getPrettyFileSize(rpc.getAccountFileSize(accountId))); - } catch (RpcException e) { - e.printStackTrace(); - } + Util.runOnAnyBackgroundThread(() -> { + try { + final int sizeBytes = rpc.getAccountFileSize(accountId); + Util.runOnMain(() -> { + sizeView.setText(Util.getPrettyFileSize(sizeBytes)); + }); + } catch (RpcException e) { + e.printStackTrace(); + } + }); description.setText(activity.getString(R.string.delete_account_explain_with_name, name)); AlertDialog dialog = new AlertDialog.Builder(activity)