@@ -51,6 +51,8 @@ public CharSequence getTransformation(CharSequence source, View view) {
5151 sp .removeSpan (vr [i ]);
5252 }
5353
54+ removeVisibleSpans (sp );
55+
5456 sp .setSpan (new ViewReference (view ), 0 , 0 ,
5557 Spannable .SPAN_POINT_POINT );
5658 }
@@ -100,10 +102,7 @@ public void onTextChanged(CharSequence s, int start,
100102 int pref = TextKeyListener .getInstance ().getPrefs (v .getContext ());
101103 if ((pref & TextKeyListener .SHOW_PASSWORD ) != 0 ) {
102104 if (count > 0 ) {
103- Visible [] old = sp .getSpans (0 , sp .length (), Visible .class );
104- for (int i = 0 ; i < old .length ; i ++) {
105- sp .removeSpan (old [i ]);
106- }
105+ removeVisibleSpans (sp );
107106
108107 if (count == 1 ) {
109108 sp .setSpan (new Visible (sp , this ), start , start + count ,
@@ -125,14 +124,18 @@ public void onFocusChanged(View view, CharSequence sourceText,
125124 if (sourceText instanceof Spannable ) {
126125 Spannable sp = (Spannable ) sourceText ;
127126
128- Visible [] old = sp .getSpans (0 , sp .length (), Visible .class );
129- for (int i = 0 ; i < old .length ; i ++) {
130- sp .removeSpan (old [i ]);
131- }
127+ removeVisibleSpans (sp );
132128 }
133129 }
134130 }
135131
132+ private static void removeVisibleSpans (Spannable sp ) {
133+ Visible [] old = sp .getSpans (0 , sp .length (), Visible .class );
134+ for (int i = 0 ; i < old .length ; i ++) {
135+ sp .removeSpan (old [i ]);
136+ }
137+ }
138+
136139 private static class PasswordCharSequence
137140 implements CharSequence , GetChars
138141 {
0 commit comments