| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.text.style; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.os.Parcel; |
| 21 |
import android.os.Parcelable; |
| 22 |
import android.text.ParcelableSpan; |
| 23 |
import android.text.TextPaint; |
| 24 |
import android.text.TextUtils; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public final class SuggestionRangeSpan extends CharacterStyle implements ParcelableSpan { |
| 31 |
private int mBackgroundColor; |
| 32 |
|
| 33 |
public SuggestionRangeSpan() { |
| 34 |
|
| 35 |
mBackgroundColor = 0; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
public SuggestionRangeSpan(@NonNull Parcel src) { |
| 40 |
mBackgroundColor = src.readInt(); |
| 41 |
} |
| 42 |
|
| 43 |
public static final @NonNull Parcelable.Creator<SuggestionRangeSpan> |
| 44 |
CREATOR = new Parcelable.Creator<SuggestionRangeSpan>() { |
| 45 |
@Override |
| 46 |
public SuggestionRangeSpan createFromParcel(Parcel source) { |
| 47 |
return new SuggestionRangeSpan(source); |
| 48 |
} |
| 49 |
|
| 50 |
@Override |
| 51 |
public SuggestionRangeSpan[] newArray(int size) { |
| 52 |
return new SuggestionRangeSpan[size]; |
| 53 |
} |
| 54 |
}; |
| 55 |
|
| 56 |
@Override |
| 57 |
public int describeContents() { |
| 58 |
return 0; |
| 59 |
} |
| 60 |
|
| 61 |
@Override |
| 62 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 63 |
writeToParcelInternal(dest, flags); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
public void writeToParcelInternal(Parcel dest, int flags) { |
| 68 |
dest.writeInt(mBackgroundColor); |
| 69 |
} |
| 70 |
|
| 71 |
@Override |
| 72 |
public int getSpanTypeId() { |
| 73 |
return getSpanTypeIdInternal(); |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
public int getSpanTypeIdInternal() { |
| 78 |
return TextUtils.SUGGESTION_RANGE_SPAN; |
| 79 |
} |
| 80 |
|
| 81 |
public void setBackgroundColor(int backgroundColor) { |
| 82 |
mBackgroundColor = backgroundColor; |
| 83 |
} |
| 84 |
|
| 85 |
public int getBackgroundColor() { |
| 86 |
return mBackgroundColor; |
| 87 |
} |
| 88 |
|
| 89 |
@Override |
| 90 |
public void updateDrawState(@NonNull TextPaint tp) { |
| 91 |
tp.bgColor = mBackgroundColor; |
| 92 |
} |
| 93 |
} |