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

fix: Input of large values in setting #602

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
// TODO: Set limits to following preferences
case KEY_SAMPLES:
samplesPref.setSummary(samplesPref.getText() + " sample" +
pluralize(Integer.valueOf(samplesPref.getText())));
pluralize(samplesPref.getText()));
break;
case KEY_BINS:
binsPref.setSummary(binsPref.getText() + " bin" +
pluralize(Integer.valueOf(binsPref.getText())));
pluralize(binsPref.getText()));
break;
case KEY_CHANNELS:
channelsPref.setSummary(channelsPref.getText() + " channel" +
pluralize(Integer.valueOf(channelsPref.getText())));
pluralize(channelsPref.getText()));
break;
default:
break;
Expand All @@ -91,15 +91,15 @@ public void onDestroyView() {
public void onResume() {
super.onResume();
samplesPref.setSummary(samplesPref.getText() + " sample" +
pluralize(Integer.valueOf(samplesPref.getText())));
pluralize(samplesPref.getText()));
binsPref.setSummary(binsPref.getText() + " bin" +
pluralize(Integer.valueOf(binsPref.getText())));
pluralize(binsPref.getText()));
channelsPref.setSummary(channelsPref.getText() + " channel" +
pluralize(Integer.valueOf(channelsPref.getText())));
pluralize(channelsPref.getText()));
}

private String pluralize(int count) {
return count > 1 ? "s" : "";
private String pluralize(String text) {
return ("0".equals(text) || "1".equals(text)) ? "" : "s";
}

@Override
Expand Down