• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.text.style;
18 
19 import android.annotation.NonNull;
20 import android.os.Parcel;
21 import android.text.ParcelableSpan;
22 import android.text.TextPaint;
23 import android.text.TextUtils;
24 
25 /**
26  * A span that strikes through the text it's attached to.
27  * <p>
28  * The span can be used like this:
29  * <pre>{@code
30  * SpannableString string = new SpannableString("Text with strikethrough span");
31  *string.setSpan(new StrikethroughSpan(), 10, 23, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);}</pre>
32  * <img src="{@docRoot}reference/android/images/text/style/strikethroughspan.png" />
33  * <figcaption>Strikethrough text.</figcaption>
34  */
35 @android.ravenwood.annotation.RavenwoodKeepWholeClass
36 public class StrikethroughSpan extends CharacterStyle
37         implements UpdateAppearance, ParcelableSpan {
38 
39     /**
40      * Creates a {@link StrikethroughSpan}.
41      */
StrikethroughSpan()42     public StrikethroughSpan() {
43     }
44 
45     /**
46      * Creates a {@link StrikethroughSpan} from a parcel.
47      */
StrikethroughSpan(@onNull Parcel src)48     public StrikethroughSpan(@NonNull Parcel src) {
49     }
50 
51     @Override
getSpanTypeId()52     public int getSpanTypeId() {
53         return getSpanTypeIdInternal();
54     }
55 
56     /** @hide */
57     @Override
getSpanTypeIdInternal()58     public int getSpanTypeIdInternal() {
59         return TextUtils.STRIKETHROUGH_SPAN;
60     }
61 
62     @Override
describeContents()63     public int describeContents() {
64         return 0;
65     }
66 
67     @Override
writeToParcel(@onNull Parcel dest, int flags)68     public void writeToParcel(@NonNull Parcel dest, int flags) {
69         writeToParcelInternal(dest, flags);
70     }
71 
72     /** @hide */
73     @Override
writeToParcelInternal(@onNull Parcel dest, int flags)74     public void writeToParcelInternal(@NonNull Parcel dest, int flags) {
75     }
76 
77     @Override
updateDrawState(@onNull TextPaint ds)78     public void updateDrawState(@NonNull TextPaint ds) {
79         ds.setStrikeThruText(true);
80     }
81 
82     @Override
toString()83     public String toString() {
84         return "StrikethroughSpan{}";
85     }
86 }
87