diff options
author | calderwoodra <calderwoodra@google.com> | 2018-01-30 14:00:24 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-30 17:43:15 -0800 |
commit | 5e550aadbb9a99885b2c719501d00a491d2ba9db (patch) | |
tree | cc9aac3387613f533cae64f0d717488717cf50aa /java/com/android/dialer/main/impl/BottomNavItem.java | |
parent | 54e90e5c61b563a432ad70066505f08b352837c3 (diff) |
Added badge count feature to bottom nav.
This Change doesn't actually fetch the badge counts, but it's now possible to
set badge counts.
Bug: 72525595
Test: manual
PiperOrigin-RevId: 183887322
Change-Id: I452ca6352133befc8cc2a39c44cd84a33fd66d42
Diffstat (limited to 'java/com/android/dialer/main/impl/BottomNavItem.java')
-rw-r--r-- | java/com/android/dialer/main/impl/BottomNavItem.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/java/com/android/dialer/main/impl/BottomNavItem.java b/java/com/android/dialer/main/impl/BottomNavItem.java index 14706ab34..af7399b6c 100644 --- a/java/com/android/dialer/main/impl/BottomNavItem.java +++ b/java/com/android/dialer/main/impl/BottomNavItem.java @@ -22,15 +22,18 @@ import android.support.annotation.DrawableRes; import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.util.AttributeSet; +import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import com.android.dialer.common.Assert; /** Navigation item in a bottom nav. */ final class BottomNavItem extends LinearLayout { private ImageView image; private TextView text; + private TextView notificationBadge; public BottomNavItem(Context context, @Nullable AttributeSet attrs) { super(context, attrs); @@ -41,6 +44,7 @@ final class BottomNavItem extends LinearLayout { super.onFinishInflate(); image = findViewById(R.id.bottom_nav_item_image); text = findViewById(R.id.bottom_nav_item_text); + notificationBadge = findViewById(R.id.notification_badge); } @Override @@ -56,4 +60,14 @@ final class BottomNavItem extends LinearLayout { text.setText(stringRes); image.setImageResource(drawableRes); } + + void setNotificationCount(int count) { + Assert.checkArgument(count >= 0, "Invalid count: " + count); + if (count == 0) { + notificationBadge.setVisibility(View.GONE); + } else { + notificationBadge.setVisibility(View.VISIBLE); + notificationBadge.setText(String.format(Integer.toString(count))); + } + } } |