+ final TextWatcher amountWatcher = new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+ }
+ @Override
+ public void afterTextChanged(Editable s) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ // only one decimal separator is allowed
+ // plus and minus are allowed only at the beginning
+ String val = s.toString();
+ if (val.isEmpty())
+ tvAmount.setKeyListener(DigitsKeyListener.getInstance(
+ "0123456789+-" + decimalSeparator + decimalDot));
+ else if (val.contains(decimalSeparator) || val.contains(decimalDot))
+ tvAmount.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
+ else
+ tvAmount.setKeyListener(DigitsKeyListener.getInstance(
+ "0123456789" + decimalSeparator + decimalDot));
+
+ syncData();
+ adapter.model.checkTransactionSubmittable(adapter);
+ }
+ }
+ };