Fixed DateSortedList
This commit is contained in:
@@ -8,4 +8,9 @@ public class EventList extends DateSortedList<Event> {
|
|||||||
public long getDateByItem(Event item) {
|
public long getDateByItem(Event item) {
|
||||||
return item.getEndDate();
|
return item.getEndDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean reversed() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,30 +11,29 @@ public abstract class DateSortedList<T> extends ArrayList<T> {
|
|||||||
public T getPast(int index) {
|
public T getPast(int index) {
|
||||||
if (split < 0)
|
if (split < 0)
|
||||||
sort();
|
sort();
|
||||||
if (index >= split)
|
if (index >= this.sizePast())
|
||||||
throw new ArrayIndexOutOfBoundsException(String.format("Index %d out of bounds! Only %d past events found!", index, split));
|
throw new ArrayIndexOutOfBoundsException(String.format("Index %d out of bounds! Only %d past events found!", index, split));
|
||||||
if (reversed())
|
if (reversed())
|
||||||
index = sizePast() - index - 1;
|
index += sizeUpcoming();
|
||||||
return this.get(index);
|
return this.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getUpcoming(int index) {
|
public T getUpcoming(int index) {
|
||||||
if (split < 0)
|
if (split < 0)
|
||||||
sort();
|
sort();
|
||||||
index += split;
|
if (index >= this.sizeUpcoming())
|
||||||
if (index >= this.size())
|
|
||||||
throw new ArrayIndexOutOfBoundsException(String.format("Index %d out of bounds! Only %d upcoming events found!", index-split, this.size()-split));
|
throw new ArrayIndexOutOfBoundsException(String.format("Index %d out of bounds! Only %d upcoming events found!", index-split, this.size()-split));
|
||||||
if (reversed())
|
if (!reversed())
|
||||||
index = sizeUpcoming() - index - 1;
|
index += this.sizePast();
|
||||||
return this.get(index);
|
return this.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get(int index) {
|
public T get(int index) {
|
||||||
//if (split < 0)
|
if (split < 0)
|
||||||
// sort();
|
sort();
|
||||||
if (reversed())
|
if (reversed())
|
||||||
index = size() - index - 1;
|
index = size() - 1 - index;
|
||||||
return super.get(index);
|
return super.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ buildscript {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url "https://jitpack.io"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||||
@@ -18,6 +21,9 @@ allprojects {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url "https://jitpack.io"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gradle.projectsEvaluated {
|
gradle.projectsEvaluated {
|
||||||
|
|||||||
Reference in New Issue
Block a user