Changed few names to be able to incorporate news in future.

This commit is contained in:
Robert Kolner committed 2011-11-02 21:54:23 +01:00
1 parent 55e56123d7
commit 51b41a4253
5 files changed
+19 -16

No files matched your search

@@ -9,9 +9,9 @@ public class DataHandler {
private List<Event> events = new LinkedList<Event>();
private Set<String> categories = new TreeSet<String>();
public void insert(String id, String title, String description, String date, String location, String text, String category) {
public void insertEvent(String id, String title, String description, String date, String location, String text, String category) {
int intId = Integer.parseInt(id);
if (get(intId) != null)
if (getEvent(intId) != null)
return;
Event e = new Event(intId, title, description, date, location, text, category);
@@ -19,7 +19,7 @@ public class DataHandler {
categories.add(category);
}
public Event get(int id) {
public Event getEvent(int id) {
for (Event e : events) {
if (e.id == id)
return e;
@@ -27,7 +27,7 @@ public class DataHandler {
return null;
}
public Event[] populateList(String category) {
public Event[] populateEventList(String category) {
LinkedList<Event> sorted = new LinkedList<Event>();
if (category.equals(Event.ALL)) {
@@ -41,7 +41,7 @@ public class DataHandler {
return sorted.toArray(new Event[sorted.size()]);
}
public String[] getCategories() {
public String[] getEventCategories() {
String[] result = new String[categories.size() + 1];
result[0] = Event.ALL;
@@ -0,0 +1,5 @@
package com.studentersamfundet.app;
public class RSSParserNews {
}
@@ -4,10 +4,10 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class XmlParser {
public class RSSParserProgram {
private static DataHandler dh;
public XmlParser() {
public RSSParserProgram() {
dh = new DataHandler();
}
@@ -64,7 +64,7 @@ public class XmlParser {
if (textTextNodes.getLength() > 0) text = textTextNodes.item(0).getNodeValue();
if (categoryTextNodes.getLength() > 0) category = categoryTextNodes.item(0).getNodeValue();
dh.insert(id, title, description, date, location, text, category);
dh.insertEvent(id, title, description, date, location, text, category);
}
}
return dh;
@@ -42,8 +42,6 @@ public class DnsActivity extends BaseDnsActivity {
int day = (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) + 5) % 7;
tvNeuf.setText(openingHoursHouse[day]);
// +"\nKjøkkenet - 19.00"
tvBC.setText(openingHoursBC[day]);
}
@@ -67,7 +65,7 @@ public class DnsActivity extends BaseDnsActivity {
startActivity(intent);
}
public void streamButton(View v) {
public void newsButton(View v) {
Toast.makeText(this, "Not implemented (yet!)", Toast.LENGTH_SHORT).show();
}
@@ -30,14 +30,14 @@ import com.studentersamfundet.app.DataHandler;
import com.studentersamfundet.app.Event;
import com.studentersamfundet.app.FeedFetcher;
import com.studentersamfundet.app.R;
import com.studentersamfundet.app.XmlParser;
import com.studentersamfundet.app.RSSParserProgram;
import com.studentersamfundet.app.ui.ChooseCategoryDialog.Callback;
public class ProgramListActivity extends BaseDnsActivity {
public static final String feedURL = "http://studentersamfundet.no/rss/lars_program_feed.php";
private FeedFetcher feed;
private XmlParser parser;
private RSSParserProgram parser;
private DataHandler dataHandler;
private String currentCategory = Event.ALL;
@@ -48,7 +48,7 @@ public class ProgramListActivity extends BaseDnsActivity {
setContentView(R.layout.event_list);
this.feed = new FeedFetcher(this, feedURL);
this.parser = new XmlParser();
this.parser = new RSSParserProgram();
ListCreator lc = new ListCreator(Event.ALL, false);
lc.execute();
@@ -91,7 +91,7 @@ public class ProgramListActivity extends BaseDnsActivity {
protected ListAdapter createAdapter(String category) {
Event[] events = dataHandler.populateList(category);
Event[] events = dataHandler.populateEventList(category);
ListAdapter adapter = new ArrayAdapter<Event>(this, R.layout.event_list_row, R.id.event_list_row_text, events) {
@Override
@@ -181,7 +181,7 @@ public class ProgramListActivity extends BaseDnsActivity {
};
if (dataHandler != null) {
Dialog dialog = new ChooseCategoryDialog(this, callback, dataHandler.getCategories());
Dialog dialog = new ChooseCategoryDialog(this, callback, dataHandler.getEventCategories());
dialog.show();
} else {
Toast.makeText(this, R.string.error_loading, Toast.LENGTH_SHORT);