use of com.mobsandgeeks.saripaar.Validator in project android-saripaar by ragunathjawahar.
the class QuickRuleUnorderedActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quick_rule_unordered);
// UI References
mZipCodeEditText = (EditText) findViewById(R.id.zipCodeEditText);
mAirtelNumberEditText = (EditText) findViewById(R.id.airtelNumberEditText);
mResultTextView = (TextView) findViewById(R.id.resultTextView);
mUseQuickRuleRadioButton = (RadioButton) findViewById(R.id.useQuickRuleRadioButton);
mSaripaarButton = (Button) findViewById(R.id.saripaarButton);
// Validator
mValidator = new Validator(this);
mValidator.setValidationListener(this);
// Event Listeners
mUseQuickRuleRadioButton.setOnCheckedChangeListener(this);
mSaripaarButton.setOnClickListener(this);
}
use of com.mobsandgeeks.saripaar.Validator in project android-saripaar by ragunathjawahar.
the class QuickRuleUnorderedInOrderedActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quick_rule_unordered_in_ordered);
// UI References
mZipCodeEditText = (EditText) findViewById(R.id.zipCodeEditText);
mAirtelNumberEditText = (EditText) findViewById(R.id.airtelNumberEditText);
mResultTextView = (TextView) findViewById(R.id.resultTextView);
mUseQuickRuleRadioButton = (RadioButton) findViewById(R.id.useQuickRuleRadioButton);
mSaripaarButton = (Button) findViewById(R.id.saripaarButton);
// Validator
mValidator = new Validator(this);
mValidator.setValidationListener(this);
// Quick Rule for ORDERED field
mValidator.put(mAirtelNumberEditText, new QuickRule<TextView>() {
@Override
public boolean isValid(TextView textView) {
final String phoneNumber = textView.getText().toString().trim();
return phoneNumber.length() == 10 && phoneNumber.startsWith("999");
}
@Override
public String getMessage(Context context) {
return "Not an Airtel number :(";
}
});
// Event Listeners
mUseQuickRuleRadioButton.setOnCheckedChangeListener(this);
mSaripaarButton.setOnClickListener(this);
}
use of com.mobsandgeeks.saripaar.Validator 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);
}
});
}
use of com.mobsandgeeks.saripaar.Validator in project android-saripaar by ragunathjawahar.
the class UnorderedSequencingActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_un_ordered_sequencing);
// UI References
mNameEditText = (EditText) findViewById(R.id.nameEditText);
mAddressEditText = (EditText) findViewById(R.id.addressEditText);
mEmailEditText = (EditText) findViewById(R.id.emailEditText);
mPhoneEditText = (EditText) findViewById(R.id.phoneEditText);
mResultTextView = (TextView) findViewById(R.id.resultTextView);
RadioGroup modeRadioGroup = (RadioGroup) findViewById(R.id.modeRadioGroup);
Button saripaarButton = (Button) findViewById(R.id.saripaarButton);
// Validator
mValidator = new Validator(this);
mValidator.setValidationListener(this);
// Event listeners
modeRadioGroup.setOnCheckedChangeListener(this);
saripaarButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
mValidator.validate();
} catch (IllegalStateException e) {
mResultTextView.setText(R.string.crash);
}
}
});
}
use of com.mobsandgeeks.saripaar.Validator in project android-saripaar by ragunathjawahar.
the class UnorderedValidateBeforeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_un_ordered_validate_till_before);
// UI References
mNameEditText = (EditText) findViewById(R.id.nameEditText);
mAddressEditText = (EditText) findViewById(R.id.addressEditText);
mEmailEditText = (EditText) findViewById(R.id.emailEditText);
mPhoneEditText = (EditText) findViewById(R.id.phoneEditText);
mResultTextView = (TextView) findViewById(R.id.resultTextView);
RadioGroup modeRadioGroup = (RadioGroup) findViewById(R.id.modeRadioGroup);
// Validator
mValidator = new Validator(this);
mValidator.setValidationListener(this);
// Event listeners
mNameEditText.setOnFocusChangeListener(this);
mAddressEditText.setOnFocusChangeListener(this);
mEmailEditText.setOnFocusChangeListener(this);
mPhoneEditText.setOnFocusChangeListener(this);
modeRadioGroup.setOnCheckedChangeListener(this);
}
Aggregations