Skip to content

Commit

Permalink
fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
AliAzaz committed Apr 29, 2019
1 parent 69242df commit cbe39a6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public EditTextPicker(Context context, AttributeSet attrs) {
//Pattern
pattern = a.getString(R.styleable.EditTextPicker_pattern);

// For mask
mask = a.getString(R.styleable.EditTextPicker_mask);
if (mask != null) {
if (!mask.trim().isEmpty()) {
maskingEditText(mask);
}
}

//For type -> range and equal
type = a.getInteger(R.styleable.EditTextPicker_type, 0);
if (type == 1) {
Expand All @@ -59,17 +67,9 @@ public EditTextPicker(Context context, AttributeSet attrs) {
throw new RuntimeException("Default value not provided");
}

// For mask
mask = a.getString(R.styleable.EditTextPicker_mask);
if (mask != null) {
if (!mask.trim().isEmpty()) {
maskingEditText(mask);
}
}


} catch (Exception e) {
Log.e(TAG, "TextPicker: ", e);
throw e;
} finally {
a.recycle();
}
Expand Down Expand Up @@ -183,6 +183,7 @@ public boolean isEmptyTextBox() {

// call for checking range textbox
public boolean isRangeTextValidate() {
if (type != 1) return true;
if (!required) return true;
if (!isEmptyTextBox()) return false;
if (!checkingPattern()) return false;
Expand Down Expand Up @@ -221,16 +222,17 @@ public boolean isRangeTextValidate() {
public boolean isTextEqualToPattern() {
if (!required) return true;
if (!isEmptyTextBox()) return false;
if (!checkingPattern()) {
if (!super.getText().toString().equals(String.valueOf(defaultvalue))) return false;
}
if (!checkingPattern())
if (type == 2) {
if (!super.getText().toString().equals(String.valueOf(defaultvalue))) return false;
} else return false;
super.setError(null);
super.clearFocus();
invalidate();
return true;
}

public boolean checkingPattern() {
private boolean checkingPattern() {
if (pattern == null) return true;
if (!super.getText().toString().matches(pattern)) {
super.setError("Not match to pattern!!");
Expand Down

0 comments on commit cbe39a6

Please sign in to comment.