DateSortedList Sorting bug fix
This commit is contained in:
@@ -7,6 +7,7 @@ import java.util.Iterator;
|
||||
|
||||
public abstract class DateSortedList<T> extends ArrayList<T> {
|
||||
private int split = -1;
|
||||
private boolean mSorting = false;
|
||||
|
||||
public T getPast(int index) {
|
||||
if (split < 0)
|
||||
@@ -30,6 +31,7 @@ public abstract class DateSortedList<T> extends ArrayList<T> {
|
||||
|
||||
@Override
|
||||
public T get(int index) {
|
||||
if (mSorting) return super.get(index);
|
||||
if (split < 0)
|
||||
sort();
|
||||
if (reversed())
|
||||
@@ -55,6 +57,7 @@ public abstract class DateSortedList<T> extends ArrayList<T> {
|
||||
}
|
||||
|
||||
public void sort() {
|
||||
mSorting = true;
|
||||
Collections.sort(this, ((e1, e2) -> Long.compare(getDateByItem(e1), getDateByItem(e2))));
|
||||
long now = System.currentTimeMillis();
|
||||
split = 0;
|
||||
@@ -64,6 +67,7 @@ public abstract class DateSortedList<T> extends ArrayList<T> {
|
||||
else
|
||||
break;
|
||||
}
|
||||
mSorting = false;
|
||||
}
|
||||
|
||||
public Iterator<T> getEventsOfMonth(int year, int month) {
|
||||
|
||||
Reference in New Issue
Block a user