blob: e0e5351b8b3d0af1e506fef7eecf76a21ab8533e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package cgeo.geocaching;
import org.xml.sax.XMLReader;
import android.text.Editable;
import android.text.Html.TagHandler;
import android.text.Spanned;
import android.text.style.StrikethroughSpan;
public class UnknownTagsHandler implements TagHandler {
private static final int UNDEFINED_POSITION = -1;
int strikePos = UNDEFINED_POSITION;
public void handleTag(boolean opening, String tag, Editable output,
XMLReader xmlReader) {
if (tag.equalsIgnoreCase("strike") || tag.equals("s")) {
handleStrike(opening, output);
}
}
private void handleStrike(boolean opening, Editable output) {
int length = output.length();
if (opening) {
strikePos = length;
} else {
if (strikePos > UNDEFINED_POSITION) {
output.setSpan(new StrikethroughSpan(), strikePos, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
strikePos = UNDEFINED_POSITION;
}
}
}
}
|