0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 20:03:05 +02:00

Merge pull request #3909 from hssm/decklist-nesting-ordering

Fix crash when loading decklist
This commit is contained in:
Nicolas Raoul 2015-12-01 13:11:10 +09:00
commit 8b94904017

View File

@ -2549,7 +2549,23 @@ public class Sched {
*/
@Override
public int compareTo(Object other) {
return this.names[0].compareTo(((DeckDueTreeNode)other).names[0]);
DeckDueTreeNode rhs = (DeckDueTreeNode) other;
// Consider each subdeck name in the ordering
for (int i = 0; i < names.length && i < rhs.names.length; i++) {
int cmp = names[i].compareTo(rhs.names[i]);
if (cmp == 0) {
continue;
}
return cmp;
}
// If we made it this far then the arrays are of different length. The longer one should
// always come after since it contains all of the sections of the shorter one inside it
// (i.e., the short one is an ancestor of the longer one).
if (rhs.names.length > names.length) {
return -1;
} else {
return 1;
}
}
@Override