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.
This commit is contained in:
B. Petersen
2024-11-12 18:01:02 +01:00
committed by bjoern
parent 1355303360
commit 9f3eeb3d0d
@@ -168,11 +168,16 @@ public class AccountSelectionListFragment extends DialogFragment
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)