Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ediTextIban.addTextChangedListener(new TextWatcher() {
- String lastValue;
- @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) {
- String newValue = ediTextIban.getText().toString();
- newValue = newValue.replace("TR", "").replace("TR", "").replace(" ", "");
- if (newValue.length() > 32) {
- newValue = newValue.substring(0, 32);
- }
- if (newValue.matches("\d+(?:\.\d+)?")) {
- newValue = ("TR" + newValue).replaceAll("(\w{4})", "$1 ").trim();
- if (!newValue.equals(lastValue)) {
- lastValue = newValue;
- ediTextIban.setText(newValue);
- if (newValue.length() > 0) {
- ediTextIban.setSelection(newValue.length());
- }
- if (ediTextIban.getText().toString().length() == 32) {
- getIbanInfo(s.toString().replaceAll(" ", ""));
- ediTextIban.clearFocus();
- editTextTutar.requestFocus();
- } else if (layoutAliciHesapSahibiHavale.getVisibility() == View.VISIBLE) {
- setReceiverAccount(null);
- }
- }
- } else {
- newValue = "TR";
- if (ediTextIban.getText().toString().length() < 2) {
- lastValue = newValue;
- ediTextIban.setText(newValue);
- ediTextIban.setSelection(newValue.length());
- }
- }
- }
- });
Add Comment
Please, Sign In to add comment