mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-13 03:48:07 -04:00
Cleanups
This commit is contained in:
@@ -110,10 +110,6 @@ public class ManageGroupsActivity extends CatimaAppCompatActivity implements Gro
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private String sanitizeAddGroupNameField(CharSequence s) {
|
||||
return s.toString().trim();
|
||||
}
|
||||
|
||||
private void createGroup() {
|
||||
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this);
|
||||
|
||||
@@ -143,7 +139,7 @@ public class ManageGroupsActivity extends CatimaAppCompatActivity implements Gro
|
||||
|
||||
// Buttons
|
||||
builder.setPositiveButton(getString(R.string.ok), (dialog, which) -> {
|
||||
DBHelper.insertGroup(mDatabase, sanitizeAddGroupNameField(input.getText()));
|
||||
DBHelper.insertGroup(mDatabase, input.getText().toString().trim());
|
||||
updateGroupList();
|
||||
});
|
||||
builder.setNegativeButton(getString(R.string.cancel), (dialog, which) -> dialog.cancel());
|
||||
@@ -152,15 +148,15 @@ public class ManageGroupsActivity extends CatimaAppCompatActivity implements Gro
|
||||
// Now that the dialog exists, we can bind something that affects the OK button
|
||||
input.addTextChangedListener(new SimpleTextWatcher() {
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
String string = sanitizeAddGroupNameField(input.getText());
|
||||
String groupName = s.toString().trim();
|
||||
|
||||
if (string.length() == 0) {
|
||||
if (groupName.length() == 0) {
|
||||
input.setError(getString(R.string.group_name_is_empty));
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DBHelper.getGroup(mDatabase, string) != null) {
|
||||
if (DBHelper.getGroup(mDatabase, groupName) != null) {
|
||||
input.setError(getString(R.string.group_name_already_in_use));
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user