ReplacementTransformationMethodpublic abstract class ReplacementTransformationMethod extends Object implements TransformationMethodThis transformation method causes the characters in the {@link #getOriginal}
array to be replaced by the corresponding characters in the
{@link #getReplacement} array. |
Methods Summary |
---|
protected abstract char[] | getOriginal()Returns the list of characters that are to be replaced by other
characters when displayed.
| protected abstract char[] | getReplacement()Returns a parallel array of replacement characters for the ones
that are to be replaced.
| public java.lang.CharSequence | getTransformation(java.lang.CharSequence source, android.view.View v)Returns a CharSequence that will mirror the contents of the
source CharSequence but with the characters in {@link #getOriginal}
replaced by ones from {@link #getReplacement}.
char[] original = getOriginal();
char[] replacement = getReplacement();
/*
* Short circuit for faster display if the text will never change.
*/
if (!(source instanceof Editable)) {
/*
* Check whether the text does not contain any of the
* source characters so can be used unchanged.
*/
boolean doNothing = true;
int n = original.length;
for (int i = 0; i < n; i++) {
if (TextUtils.indexOf(source, original[i]) >= 0) {
doNothing = false;
break;
}
}
if (doNothing) {
return source;
}
if (!(source instanceof Spannable)) {
/*
* The text contains some of the source characters,
* but they can be flattened out now instead of
* at display time.
*/
if (source instanceof Spanned) {
return new SpannedString(new SpannedReplacementCharSequence(
(Spanned) source,
original, replacement));
} else {
return new ReplacementCharSequence(source,
original,
replacement).toString();
}
}
}
if (source instanceof Spanned) {
return new SpannedReplacementCharSequence((Spanned) source,
original, replacement);
} else {
return new ReplacementCharSequence(source, original, replacement);
}
| public void | onFocusChanged(android.view.View view, java.lang.CharSequence sourceText, boolean focused, int direction, android.graphics.Rect previouslyFocusedRect)
// This callback isn't used.
|
|