Skip to content

Conversation

@javidesmaeeli
Copy link

Overload a new function for BottomBarBadge.setCount to allow specifying if the badge text should be formatted (summarized) for large counts (1000~1999 to 1K, and so on) which reduces the length of badge text by 2 for large badges, resulting in a more appealing badge.
The default behavior for the setCount(int count) is not altered.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 63.406% when pulling aa2e75d on javidesmaeeli:option-to-format-large-badge-counts into 711fcaf on roughike:master.

Copy link

@sadegh sadegh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 👍

this.count = count;
setText(String.valueOf(count));
if (formatBadge && count > 1000) {
setText(String.format(getResources().getString(R.string.badge_format), count / 1000));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R.string.badge_format can be defined as %1$dK, then you can use it without calling String.format() as follows:
getResources().getString(R.string.badge_format), count / 1000).

@leonardo2204
Copy link
Contributor

check #859 to see if it helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants