Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally specify to format the badge text for large counts #817

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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