Guest User

Untitled

a guest
May 25th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. ediTextIban.addTextChangedListener(new TextWatcher() {
  2.  
  3. String lastValue;
  4.  
  5. @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  6. }
  7.  
  8. @Override public void onTextChanged(CharSequence s, int start, int before, int count) {
  9. }
  10.  
  11. @Override public void afterTextChanged(Editable s) {
  12.  
  13. String newValue = ediTextIban.getText().toString();
  14. newValue = newValue.replace("TR", "").replace("TR", "").replace(" ", "");
  15. if (newValue.length() > 32) {
  16. newValue = newValue.substring(0, 32);
  17. }
  18. if (newValue.matches("\d+(?:\.\d+)?")) {
  19. newValue = ("TR" + newValue).replaceAll("(\w{4})", "$1 ").trim();
  20. if (!newValue.equals(lastValue)) {
  21. lastValue = newValue;
  22.  
  23. ediTextIban.setText(newValue);
  24. if (newValue.length() > 0) {
  25. ediTextIban.setSelection(newValue.length());
  26. }
  27. if (ediTextIban.getText().toString().length() == 32) {
  28. getIbanInfo(s.toString().replaceAll(" ", ""));
  29. ediTextIban.clearFocus();
  30. editTextTutar.requestFocus();
  31. } else if (layoutAliciHesapSahibiHavale.getVisibility() == View.VISIBLE) {
  32. setReceiverAccount(null);
  33. }
  34. }
  35. } else {
  36. newValue = "TR";
  37. if (ediTextIban.getText().toString().length() < 2) {
  38. lastValue = newValue;
  39. ediTextIban.setText(newValue);
  40. ediTextIban.setSelection(newValue.length());
  41. }
  42. }
  43. }
  44. });
Add Comment
Please, Sign In to add comment