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

getters & setters for attributes: allowed_chars, denied_chars #15

Open
wants to merge 5 commits into
base: reqs
Choose a base branch
from
Open
Changes from 1 commit
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 @@ -4,6 +4,7 @@
import android.content.res.TypedArray;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v7.widget.AppCompatEditText;
import android.text.Editable;
import android.text.SpannableStringBuilder;
Expand Down Expand Up @@ -51,6 +52,7 @@ public MaskedEditText(Context context, AttributeSet attrs) {

TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.MaskedEditText);
mask = attributes.getString(R.styleable.MaskedEditText_mask);
if (mask == null) mask = "";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не помнишь, что эта срока делает? Это какая-то профилактика NPE?


allowedChars = attributes.getString(R.styleable.MaskedEditText_allowed_chars);
deniedChars = attributes.getString(R.styleable.MaskedEditText_denied_chars);
Expand Down Expand Up @@ -129,6 +131,7 @@ private void cleanUp() {

generatePositionArrays();

if (rawToMask.length == 0) return;
rawText = new RawText();
selection = rawToMask[0];

Expand Down Expand Up @@ -180,7 +183,6 @@ public String getAllowedChars() {

public void setAllowedChars(String allowedChars) {
this.allowedChars = allowedChars;
cleanUp();
}

public String getDeniedChars() {
Expand All @@ -189,14 +191,15 @@ public String getDeniedChars() {

public void setDeniedChars(String deniedChars) {
this.deniedChars = deniedChars;
cleanUp();
}

public String getMask() {
return this.mask;
}

public void setMask(String mask) {
public void setMask(@NonNull String mask) {
//noinspection ConstantConditions
if (mask == null) throw new NullPointerException("Mask can't be null");
this.mask = mask;
cleanUp();
}
Expand Down