use of com.mobsandgeeks.saripaar.QuickRule in project android-saripaar by ragunathjawahar.
the class RemoveRulesActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_remove_rules);
// UI References
mEmailEditText = (EditText) findViewById(R.id.emailEditText);
mAddQuickRuleRadioButton = (RadioButton) findViewById(R.id.addQuickRuleRadioButton);
mRemoveRulesRadioButton = (RadioButton) findViewById(R.id.removeRulesRadioButton);
mResultTextView = (TextView) findViewById(R.id.resultTextView);
mSaripaarButton = (Button) findViewById(R.id.saripaarButton);
// Validator
mValidator = new Validator(this);
// Event listeners
mSaripaarButton.setOnClickListener(this);
mValidator.setValidationListener(this);
mAddQuickRuleRadioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mValidator.put(mEmailEditText, new QuickRule<EditText>() {
@Override
public boolean isValid(EditText editText) {
String email = editText.getText().toString();
return email.endsWith("mobsandgeeks.com");
}
@Override
public String getMessage(Context context) {
return "Only allow emails from \"mobsandgeeks.com\" :P";
}
});
}
});
mRemoveRulesRadioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mValidator.removeRules(mEmailEditText);
}
});
}
Aggregations