diff --git a/src/com/studentersamfundet/app/DataHandler.java b/src/com/studentersamfundet/app/DataHandler.java index 8459ea8..a20efe0 100644 --- a/src/com/studentersamfundet/app/DataHandler.java +++ b/src/com/studentersamfundet/app/DataHandler.java @@ -25,7 +25,7 @@ public class DataHandler { public Event[] populateList(String category) { LinkedList sorted = new LinkedList(); - if (category.equals("all")) { + if (category.equals(Event.ALL)) { return events.toArray(new Event[events.size()]); } diff --git a/src/com/studentersamfundet/app/Event.java b/src/com/studentersamfundet/app/Event.java index a4abd28..5d8b6b9 100644 --- a/src/com/studentersamfundet/app/Event.java +++ b/src/com/studentersamfundet/app/Event.java @@ -4,6 +4,8 @@ import java.io.Serializable; public class Event implements Serializable { private static final long serialVersionUID = 1L; + public static final String ALL = "all"; + public int id; public String title; public String description; diff --git a/src/com/studentersamfundet/app/ui/ProgramListActivity.java b/src/com/studentersamfundet/app/ui/ProgramListActivity.java index 9d3e98b..e5659b8 100644 --- a/src/com/studentersamfundet/app/ui/ProgramListActivity.java +++ b/src/com/studentersamfundet/app/ui/ProgramListActivity.java @@ -41,7 +41,7 @@ public class ProgramListActivity extends BaseDnsActivity { this.feed = new FeedFetcher(this, feedURL); this.parser = new XmlParser(); - createList(false); + createList(Event.ALL, false); } @Override @@ -56,14 +56,14 @@ public class ProgramListActivity extends BaseDnsActivity { switch (item.getItemId()) { case R.id.menu_refresh: - this.createList(true); + this.createList(Event.ALL, true); return true; default: return super.onOptionsItemSelected(item); } } - protected void createList(boolean forcedUpdate) { + protected void createList(String category, boolean forcedUpdate) { // Do we have intarwebs? // YAY = Fetch the feed. // NAY = Inform about no connection. @@ -79,12 +79,12 @@ public class ProgramListActivity extends BaseDnsActivity { ListView list = (ListView)findViewById(R.id.event_list); - ListAdapter adapter = createAdapter(); + ListAdapter adapter = createAdapter(category); list.setAdapter(adapter); } - protected ListAdapter createAdapter() { - Event[] events = dataHandler.populateList("all"); + protected ListAdapter createAdapter(String category) { + Event[] events = dataHandler.populateList(category); ListAdapter adapter = new ArrayAdapter(this, R.layout.event_list_row, R.id.event_list_row_text, events) { @Override