TextInfopublic final class TextInfo extends Object implements android.os.ParcelableThis class contains a metadata of the input of TextService |
Fields Summary |
---|
private final CharSequence | mCharSequence | private final int | mCookie | private final int | mSequenceNumber | private static final int | DEFAULT_COOKIE | private static final int | DEFAULT_SEQUENCE_NUMBER | public static final Parcelable.Creator | CREATORUsed to make this class parcelable. |
Constructors Summary |
---|
public TextInfo(String text)Constructor.
this(text, 0, getStringLengthOrZero(text), DEFAULT_COOKIE, DEFAULT_SEQUENCE_NUMBER);
| public TextInfo(String text, int cookie, int sequenceNumber)Constructor.
this(text, 0, getStringLengthOrZero(text), cookie, sequenceNumber);
| public TextInfo(CharSequence charSequence, int start, int end, int cookie, int sequenceNumber)Constructor.
if (TextUtils.isEmpty(charSequence)) {
throw new IllegalArgumentException("charSequence is empty");
}
// Create a snapshot of the text including spans in case they are updated outside later.
final SpannableStringBuilder spannableString =
new SpannableStringBuilder(charSequence, start, end);
// SpellCheckSpan is for internal use. We do not want to marshal this for TextService.
final SpellCheckSpan[] spans = spannableString.getSpans(0, spannableString.length(),
SpellCheckSpan.class);
for (int i = 0; i < spans.length; ++i) {
spannableString.removeSpan(spans[i]);
}
mCharSequence = spannableString;
mCookie = cookie;
mSequenceNumber = sequenceNumber;
| public TextInfo(android.os.Parcel source)
mCharSequence = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
mCookie = source.readInt();
mSequenceNumber = source.readInt();
|
Methods Summary |
---|
public int | describeContents()Used to make this class parcelable.
return 0;
| public java.lang.CharSequence | getCharSequence()
return mCharSequence;
| public int | getCookie()
return mCookie;
| public int | getSequence()
return mSequenceNumber;
| private static int | getStringLengthOrZero(java.lang.String text)
return TextUtils.isEmpty(text) ? 0 : text.length();
| public java.lang.String | getText()
if (mCharSequence == null) {
return null;
}
return mCharSequence.toString();
| public void | writeToParcel(android.os.Parcel dest, int flags)Used to package this object into a {@link Parcel}.
TextUtils.writeToParcel(mCharSequence, dest, flags);
dest.writeInt(mCookie);
dest.writeInt(mSequenceNumber);
|
|