diff --git a/app/src/main/java/de/nicidienase/chaosflix/entities/Event.java b/app/src/main/java/de/nicidienase/chaosflix/entities/Event.java index 8a5c4663..776f98e5 100644 --- a/app/src/main/java/de/nicidienase/chaosflix/entities/Event.java +++ b/app/src/main/java/de/nicidienase/chaosflix/entities/Event.java @@ -100,6 +100,28 @@ public class Event extends SugarRecord implements Parcelable, Comparable parcel.writeString(conferenceUrl); } + @Override + public int compareTo(Event event) { + return getSlug().compareTo(event.getSlug()); + } + + @Override + public boolean equals(Object obj) { + if(obj instanceof Event){ + return getGuid().equals(((Event)obj).getGuid()); + } else { + return super.equals(obj); + } + + } + + public void update(Event e) { + if(!this.updatedAt.equals(e.getUpdatedAt())){ + // TODO actually update + this.save(); + } + } + public int getApiID(){ String[] strings = getUrl().split("/"); return Integer.parseInt(strings[strings.length-1]); @@ -268,26 +290,4 @@ public class Event extends SugarRecord implements Parcelable, Comparable public void setUpdatedAt(String updatedAt) { this.updatedAt = updatedAt; } - - @Override - public int compareTo(Event event) { - return getSlug().compareTo(event.getSlug()); - } - - @Override - public boolean equals(Object obj) { - if(obj instanceof Event){ - return getGuid().equals(((Event)obj).getGuid()); - } else { - return super.equals(obj); - } - - } - - public void update(Event e) { - if(!this.updatedAt.equals(e.getUpdatedAt())){ - // TODO actually update - this.save(); - } - } } diff --git a/app/src/main/java/de/nicidienase/chaosflix/network/MediaCCCClient.java b/app/src/main/java/de/nicidienase/chaosflix/network/MediaCCCClient.java index 4e14e054..c1cf94e2 100644 --- a/app/src/main/java/de/nicidienase/chaosflix/network/MediaCCCClient.java +++ b/app/src/main/java/de/nicidienase/chaosflix/network/MediaCCCClient.java @@ -43,6 +43,11 @@ public class MediaCCCClient implements MediaCCCService { return service.getConference(id); } + @Override + public Call> getEvents() { + return service.getEvents(); + } + @Override public Call getEvent(@Path("id") int id) { return service.getEvent(id); diff --git a/app/src/main/java/de/nicidienase/chaosflix/network/MediaCCCService.java b/app/src/main/java/de/nicidienase/chaosflix/network/MediaCCCService.java index 6baa7b37..b6d4ceff 100644 --- a/app/src/main/java/de/nicidienase/chaosflix/network/MediaCCCService.java +++ b/app/src/main/java/de/nicidienase/chaosflix/network/MediaCCCService.java @@ -22,6 +22,9 @@ public interface MediaCCCService { @GET("public/conferences/{id}") Call getConference(@Path("id") int id); + @GET("public/events") + Call> getEvents(); + @GET("public/events/{id}") Call getEvent(@Path("id") int id); diff --git a/app/src/test/java/de/nicidienase/chaosflix/MediaCCCClientTest.java b/app/src/test/java/de/nicidienase/chaosflix/MediaCCCClientTest.java index e6d55347..2c00b782 100644 --- a/app/src/test/java/de/nicidienase/chaosflix/MediaCCCClientTest.java +++ b/app/src/test/java/de/nicidienase/chaosflix/MediaCCCClientTest.java @@ -95,7 +95,6 @@ public class MediaCCCClientTest{ @Test public void sortTest(){ try { - final MediaCCCClient client = new MediaCCCClient(); Conferences conferences = client.listConferences().execute().body(); Collections.sort(conferences.getConferences()); @@ -109,4 +108,15 @@ public class MediaCCCClientTest{ fail(); } } + + @Test + public void sortAllEvents(){ + try{ + MediaCCCClient client = new MediaCCCClient(); + Collections.sort(client.getEvents().execute().body()); + } catch (IOException e) { + e.printStackTrace(); + fail(); + } + } }