blob: 87464b722d1297572b0b978087721c9267c541af (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
package org.wordpress.android.models;
import java.util.ArrayList;
public class ReaderTagList extends ArrayList<ReaderTag> {
public int indexOfTagName(String tagName) {
if (tagName == null || isEmpty()) {
return -1;
}
for (int i = 0; i < size(); i++) {
if (tagName.equals(this.get(i).getTagSlug())) {
return i;
}
}
return -1;
}
private int indexOfTag(ReaderTag tag) {
if (tag == null || isEmpty()) {
return -1;
}
for (int i = 0; i < this.size(); i++) {
if (ReaderTag.isSameTag(tag, this.get(i))) {
return i;
}
}
return -1;
}
public boolean isSameList(ReaderTagList otherList) {
if (otherList == null || otherList.size() != this.size()) {
return false;
}
for (ReaderTag otherTag: otherList) {
int i = this.indexOfTag(otherTag);
if (i == -1) {
return false;
} else if (!otherTag.getEndpoint().equals(this.get(i).getEndpoint())) {
return false;
}
}
return true;
}
/*
* returns a list of tags that are in this list but not in the passed list
*/
public ReaderTagList getDeletions(ReaderTagList otherList) {
ReaderTagList deletions = new ReaderTagList();
if (otherList == null) {
return deletions;
}
for (ReaderTag thisTag: this) {
if (otherList.indexOfTag(thisTag) == -1) {
deletions.add(thisTag);
}
}
return deletions;
}
}
|