File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
lib/java/com/google/android/material/badge Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 3838import androidx .annotation .ColorInt ;
3939import androidx .annotation .NonNull ;
4040import androidx .annotation .Nullable ;
41+ import androidx .annotation .PluralsRes ;
4142import androidx .annotation .StringRes ;
4243import androidx .annotation .StyleRes ;
4344import androidx .annotation .StyleableRes ;
@@ -133,7 +134,7 @@ public static final class SavedState implements Parcelable {
133134 private int number = BADGE_NUMBER_NONE ;
134135 private int maxCharacterCount ;
135136 private CharSequence contentDescriptionNumberless ;
136- @ StringRes private int contentDescriptionQuantityStrings ;
137+ @ PluralsRes private int contentDescriptionQuantityStrings ;
137138
138139 public SavedState (Context context ) {
139140 // If the badge text color attribute was not explicitly set, use the text color specified in
@@ -497,10 +498,14 @@ public CharSequence getContentDescription(Context context) {
497498 return null ;
498499 }
499500 if (hasNumber ()) {
500- return context
501- .getResources ()
502- .getQuantityString (
503- savedState .contentDescriptionQuantityStrings , getNumber (), getNumber ());
501+ if (savedState .contentDescriptionQuantityStrings > 0 ) {
502+ return context
503+ .getResources ()
504+ .getQuantityString (
505+ savedState .contentDescriptionQuantityStrings , getNumber (), getNumber ());
506+ } else {
507+ return null ;
508+ }
504509 } else {
505510 return savedState .contentDescriptionNumberless ;
506511 }
You can’t perform that action at this time.
0 commit comments