From 9adf11713fa5a1f8b9fc5ddb24d9f603eac3bd7e Mon Sep 17 00:00:00 2001 From: Mygod Date: Wed, 18 Nov 2015 23:15:56 +0800 Subject: [PATCH] Hide stats for profiles that have no traffic --- .../github/shadowsocks/ProfileManagerActivity.scala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala b/src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala index 975a0a38..ce69db3c 100644 --- a/src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala +++ b/src/main/scala/com/github/shadowsocks/ProfileManagerActivity.scala @@ -59,11 +59,13 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe def updateText() { val builder = new SpannableStringBuilder builder.append(item.name) - val start = builder.length - builder.append(getString(R.string.stat_profiles, - TrafficMonitor.formatTraffic(item.tx), TrafficMonitor.formatTraffic(item.rx))) - builder.setSpan(new TextAppearanceSpan(ProfileManagerActivity.this, android.R.style.TextAppearance_Small), - start + 1, builder.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + if (item.tx != 0 || item.rx != 0) { + val start = builder.length + builder.append(getString(R.string.stat_profiles, + TrafficMonitor.formatTraffic(item.tx), TrafficMonitor.formatTraffic(item.rx))) + builder.setSpan(new TextAppearanceSpan(ProfileManagerActivity.this, android.R.style.TextAppearance_Small), + start + 1, builder.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + } text.setText(builder) }