egslava/edittext-mask

Can't instantiate MaskedEditText programmatically

ildar2 opened this issue · 1 comments

You can't instantiate MaskedEditText programmatically with new MaskedEditText(mContext) constructor, because when you call setMask() there is no charRepresentation for generatePositionArrays() to match every mask char therefore rawToMask has zero length and selection = rawToMask[0]; fails with ArrayIndexOutOfBoundsException. BUT you can't setCharRepresentation() either, because mask is null and there is no null check in generatePositionArrays() on mask.length() call.
I guess setting default charRepresentation statically or setting mask to "" would fix the issue

Thanks for the report! One of the best here. Don't you want to make the pull-request, btw? I'll provide all the support for you to finish it.