Skip to content

Commit

Permalink
Add constraint of visible attachments count on badge in OpenNoteActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
zHd4 committed Dec 27, 2024
1 parent 22d2b94 commit e4efb27
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

public class OpenNoteActivity extends ExtendedAppCompatActivity {

private static final long MAX_COUNT_IN_BADGE = 9;

private final Map<Integer, Consumer<?>> menuItemsMap = new HashMap<>();
private Note note;

Expand Down Expand Up @@ -99,7 +101,11 @@ public boolean onCreateOptionsMenu(Menu menu) {
View view = Objects.requireNonNull(openAssignmentsButton.getActionView());
TextView badge = view.findViewById(R.id.attachedAssignmentsCountBadge);

badge.setText(String.valueOf(filesCount));
String badgeText = filesCount <= MAX_COUNT_IN_BADGE
? String.valueOf(filesCount)
: MAX_COUNT_IN_BADGE + "+";

badge.setText(badgeText);
badge.setVisibility(View.VISIBLE);

view.setOnClickListener(v -> openAssignmentsOnClick());
Expand Down

0 comments on commit e4efb27

Please sign in to comment.