considering possibility of null positions
parent
37b2cc7466
commit
72ee23849f
|
@ -10,9 +10,17 @@ public class VerticalPositionComparator implements Comparator<TopicType> {
|
||||||
public int compare(TopicType o1, TopicType o2) {
|
public int compare(TopicType o1, TopicType o2) {
|
||||||
final String myPosition = o1.getPosition();
|
final String myPosition = o1.getPosition();
|
||||||
final String otherPosition = o2.getPosition();
|
final String otherPosition = o2.getPosition();
|
||||||
int myPositionY = Integer.parseInt(myPosition.split(",")[1]);
|
int result;
|
||||||
int otherPositionY = Integer.parseInt(otherPosition.split(",")[1]);
|
if (otherPosition == null) {
|
||||||
return myPositionY - otherPositionY;
|
result = -1;
|
||||||
|
} else if (myPosition == null) {
|
||||||
|
result = 1;
|
||||||
|
} else {
|
||||||
|
int myPositionY = Integer.parseInt(myPosition.split(",")[1]);
|
||||||
|
int otherPositionY = Integer.parseInt(otherPosition.split(",")[1]);
|
||||||
|
result = myPositionY - otherPositionY;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue