Skip to content

Commit c8d6850

Browse files
committed
Replace Vectors with ArrayLists
1 parent 3f16cda commit c8d6850

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

WordPressUtils/src/main/java/org/wordpress/android/util/helpers/WPHtmlTagHandler.java

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77

88
import org.xml.sax.XMLReader;
99

10-
import java.util.Vector;
10+
import java.util.ArrayList;
11+
import java.util.List;
1112

1213
/**
1314
* Handle tags that the Html class doesn't understand
1415
* Tweaked from source at http://stackoverflow.com/questions/4044509/android-how-to-use-the-html-taghandler
1516
*/
1617
public class WPHtmlTagHandler implements Html.TagHandler {
1718
private int mListItemCount = 0;
18-
private Vector<String> mListParents = new Vector<String>();
19+
private List<String> mListParents = new ArrayList<>();
1920

2021
@Override
2122
public void handleTag(final boolean opening, final String tag, Editable output,
@@ -33,27 +34,30 @@ public void handleTag(final boolean opening, final String tag, Editable output,
3334
}
3435

3536
private void handleListTag(Editable output) {
36-
if (mListParents.lastElement().equals("ul")) {
37-
output.append("\n");
38-
String[] split = output.toString().split("\n");
39-
int start = 0;
40-
if (split.length != 1) {
41-
int lastIndex = split.length - 1;
42-
start = output.length() - split[lastIndex].length() - 1;
37+
int size = mListParents.size();
38+
if (size > 0) {
39+
if (mListParents.get(size - 1).equals("ul")) {
40+
output.append("\n");
41+
String[] split = output.toString().split("\n");
42+
int start = 0;
43+
if (split.length != 1) {
44+
int lastIndex = split.length - 1;
45+
start = output.length() - split[lastIndex].length() - 1;
46+
}
47+
output.setSpan(new BulletSpan(15 * mListParents.size()), start, output.length(), 0);
48+
} else if (mListParents.get(size - 1).equals("ol")) {
49+
mListItemCount++;
50+
output.append("\n");
51+
String[] split = output.toString().split("\n");
52+
int start = 0;
53+
if (split.length != 1) {
54+
int lastIndex = split.length - 1;
55+
start = output.length() - split[lastIndex].length() - 1;
56+
}
57+
output.insert(start, mListItemCount + ". ");
58+
output.setSpan(new LeadingMarginSpan.Standard(15 * mListParents.size()), start,
59+
output.length(), 0);
4360
}
44-
output.setSpan(new BulletSpan(15 * mListParents.size()), start, output.length(), 0);
45-
} else if (mListParents.lastElement().equals("ol")) {
46-
mListItemCount++;
47-
output.append("\n");
48-
String[] split = output.toString().split("\n");
49-
int start = 0;
50-
if (split.length != 1) {
51-
int lastIndex = split.length - 1;
52-
start = output.length() - split[lastIndex].length() - 1;
53-
}
54-
output.insert(start, mListItemCount + ". ");
55-
output.setSpan(new LeadingMarginSpan.Standard(15 * mListParents.size()), start,
56-
output.length(), 0);
5761
}
5862
}
5963
}

0 commit comments

Comments
 (0)