Archived
Further adjustments were made to conform to new RSS format.
This commit is contained in:
1 parent
48b5fad7c3
commit
3d8a94121d
2 files changed
+41
-5
No files matched your search
@@ -5,6 +5,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
public class DataHandler {
|
||||
private List<Event> events = new LinkedList<Event>();
|
||||
private List<News> news = new LinkedList<News>();
|
||||
@@ -20,13 +22,28 @@ public class DataHandler {
|
||||
String imageUri,
|
||||
String priceReg,
|
||||
String priceMem,
|
||||
String ticketUri) {
|
||||
String ticketUriStr) {
|
||||
int intId = Integer.parseInt(id);
|
||||
if (getEvent(intId) != null)
|
||||
return;
|
||||
|
||||
Event e = new Event(intId, title, description, date, location, text, category, imageUri);
|
||||
events.add(e);
|
||||
Event event = new Event(intId, title, description, date, location, text, category, imageUri);
|
||||
|
||||
try {
|
||||
int regularPrice = Integer.parseInt(priceReg);
|
||||
int memberPrice = Integer.parseInt(priceMem);
|
||||
Uri ticketUri = null;
|
||||
|
||||
if (ticketUriStr.startsWith("http://") && ticketUriStr.length() > 7) {
|
||||
ticketUri = Uri.parse(ticketUriStr);
|
||||
}
|
||||
|
||||
event.setTicketsInfo(regularPrice, memberPrice, ticketUri);
|
||||
} catch (NumberFormatException e1) { /* Do nothing. */
|
||||
} catch (NullPointerException e2) { /* That's correct, catch NullPointerExceptions. */ }
|
||||
|
||||
|
||||
events.add(event);
|
||||
eventCategories.add(category);
|
||||
}
|
||||
|
||||
@@ -36,6 +53,7 @@ public class DataHandler {
|
||||
}
|
||||
|
||||
public Event getEvent(int id) {
|
||||
/* TODO: This has linear time complexity. Fix needed? */
|
||||
for (Event e : events) {
|
||||
if (e.id == id)
|
||||
return e;
|
||||
@@ -44,11 +62,11 @@ public class DataHandler {
|
||||
}
|
||||
|
||||
public Event[] populateEventList(String category) {
|
||||
LinkedList<Event> sorted = new LinkedList<Event>();
|
||||
|
||||
if (category.equals(Event.ALL)) {
|
||||
return events.toArray(new Event[events.size()]);
|
||||
}
|
||||
|
||||
LinkedList<Event> sorted = new LinkedList<Event>();
|
||||
|
||||
for (Event event : events) {
|
||||
if (category.equals(event.getCategory()))
|
||||
@@ -57,6 +75,18 @@ public class DataHandler {
|
||||
return sorted.toArray(new Event[sorted.size()]);
|
||||
}
|
||||
|
||||
public Event[] getAllEventsWithTickets() {
|
||||
LinkedList<Event> list = new LinkedList<Event>();
|
||||
|
||||
for (Event event : events) {
|
||||
if(event.getTicketUri() != null) {
|
||||
list.add(event);
|
||||
}
|
||||
}
|
||||
|
||||
return list.toArray(new Event[list.size()]);
|
||||
}
|
||||
|
||||
public News[] populateNewsList() {
|
||||
return this.news.toArray(new News[this.news.size()]);
|
||||
}
|
||||
|
||||
@@ -97,4 +97,10 @@ public class Event implements Serializable {
|
||||
public Uri getTicketUri() {
|
||||
return this.ticketUri;
|
||||
}
|
||||
|
||||
public void setTicketsInfo(int regularPrice, int memberPrice, Uri ticketUri) {
|
||||
this.regularPrice = regularPrice;
|
||||
this.memberPrice = memberPrice;
|
||||
this.ticketUri = ticketUri;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user