Exponent can't be first in number

+ tests for NumberInputFilter
This commit is contained in:
serso
2016-04-15 22:53:44 +02:00
parent 76b8901a4e
commit 28a573c777
2 changed files with 116 additions and 1 deletions

View File

@@ -61,7 +61,7 @@ public class NumberInputFilter implements InputFilter {
findChars(dest, dend, dest.length(), end - start, CHARS);
SpannableStringBuilder filtered = null;
for (int i = end - 1; i >= start; i--) {
for (int i = start; i < end; i++) {
final char c = source.charAt(i);
boolean filter = false;
@@ -93,6 +93,9 @@ public class NumberInputFilter implements InputFilter {
} else if (CHARS[CHAR_POINT] >= 0 && CHARS[CHAR_POINT] > i + dstart) {
// no exponent before decimal point
filter = true;
} else if (i + dstart == 0) {
// exponent can't be first
filter = true;
} else {
CHARS[CHAR_EXP] = i + dstart;
}