Skip to content

Commit

Permalink
calculate account size in background
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
r10s committed Nov 12, 2024
1 parent 1355303 commit 9f3eeb3
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9f3eeb3

Please sign in to comment.