Skip to content

Commit

Permalink
Show IPv6 percentage as integer
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuele-f committed Mar 11, 2024
1 parent d17fffe commit ec25c18
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ private void updateStats(CaptureStats stats) {
mIPv6BytesSent.setText(Utils.formatBytes(stats.ipv6_bytes_sent));
mIPv6BytesRcvd.setText(Utils.formatBytes(stats.ipv6_bytes_rcvd));

float percentage = ((stats.bytes_sent + stats.bytes_rcvd) > 0) ?
((float)(stats.ipv6_bytes_sent + stats.ipv6_bytes_rcvd) /
(float)(stats.bytes_sent + stats.bytes_rcvd)) : 0;
long tot_bytes = stats.bytes_sent + stats.bytes_rcvd;
long percentage = (tot_bytes > 0) ?
((stats.ipv6_bytes_sent + stats.ipv6_bytes_rcvd) * 100 / tot_bytes) : 0;
mIPv6BytesPercentage.setText(
String.format(Utils.getPrimaryLocale(this),"%.02f%%", 100*percentage));
String.format(Utils.getPrimaryLocale(this),"%d%%", percentage));

mPacketsSent.setText(Utils.formatIntShort(stats.pkts_sent));
mPacketsRcvd.setText(Utils.formatIntShort(stats.pkts_rcvd));
Expand Down

0 comments on commit ec25c18

Please sign in to comment.