diff --git a/src/com/studentersamfundet/app/DataHandler.java b/src/com/studentersamfundet/app/DataHandler.java index 0fa0291..5fa548d 100644 --- a/src/com/studentersamfundet/app/DataHandler.java +++ b/src/com/studentersamfundet/app/DataHandler.java @@ -5,12 +5,12 @@ import java.util.LinkedList; public class DataHandler { private LinkedList events = new LinkedList(); - public void insert(String id, String title, String description, String date, String location, String category) { + public void insert(String id, String title, String description, String date, String location, String text, String category) { int intId = Integer.parseInt(id); if (get(intId) != null) return; - Event e = new Event(intId, title, description, date, location, category); + Event e = new Event(intId, title, description, date, location, text, category); events.add(e); } diff --git a/src/com/studentersamfundet/app/Event.java b/src/com/studentersamfundet/app/Event.java index b97f1c7..7aea4a4 100644 --- a/src/com/studentersamfundet/app/Event.java +++ b/src/com/studentersamfundet/app/Event.java @@ -9,6 +9,7 @@ public class Event implements Serializable { public String description; public String date; public String location; + public String text; public String category; public Event( @@ -16,13 +17,15 @@ public class Event implements Serializable { String title, String description, String date, - String location, + String location, + String text, String category) { this.id = id; this.title = title; this.description = description; this.date = date; this.location = location; + this.text = text; this.category = category; } diff --git a/src/com/studentersamfundet/app/XmlParser.java b/src/com/studentersamfundet/app/XmlParser.java index 3e4b30a..c24162f 100644 --- a/src/com/studentersamfundet/app/XmlParser.java +++ b/src/com/studentersamfundet/app/XmlParser.java @@ -17,6 +17,7 @@ public class XmlParser { String description = ""; String date = ""; String location = ""; + String text = ""; String category = ""; // String pictureUrl = ""; Necessary? @@ -33,6 +34,7 @@ public class XmlParser { NodeList descriptionNodes = (itemElement).getElementsByTagName("description"); NodeList dateNodes = (itemElement).getElementsByTagName("date"); NodeList locationNodes = (itemElement).getElementsByTagName("location"); + NodeList textNodes = (itemElement).getElementsByTagName("text"); NodeList categoryNodes = (itemElement).getElementsByTagName("category"); // Convert a Node into an Element. @@ -41,6 +43,7 @@ public class XmlParser { Node descriptionElement = descriptionNodes.item(0); Node dateElement = dateNodes.item(0); Node locationElement = locationNodes.item(0); + Node textElement = textNodes.item(0); Node categoryElement = categoryNodes.item(0); // Get all the child nodes. @@ -49,16 +52,19 @@ public class XmlParser { NodeList descriptionTextNodes = descriptionElement.getChildNodes(); NodeList dateTextNodes = dateElement.getChildNodes(); NodeList locationTextNodes = locationElement.getChildNodes(); + NodeList textTextNodes = textElement.getChildNodes(); NodeList categoryTextNodes = categoryElement.getChildNodes(); // Retrieve the text. - id = idTextNodes.item(0).getNodeValue(); - title = titleTextNodes.item(0).getNodeValue(); - description = descriptionTextNodes.item(0).getNodeValue(); - date = dateTextNodes.item(0).getNodeValue(); - location = locationTextNodes.item(0).getNodeValue(); - category = categoryTextNodes.item(0).getNodeValue(); - dh.insert(id, title, description, date, location, category); + id = idTextNodes.item(0).getNodeValue(); // mandatory + title = titleTextNodes.item(0).getNodeValue(); // mandatory + if (descriptionTextNodes.getLength() > 0) description = descriptionTextNodes.item(0).getNodeValue(); + if (dateTextNodes.getLength() > 0) date = dateTextNodes.item(0).getNodeValue(); + if (locationTextNodes.getLength() > 0) location = locationTextNodes.item(0).getNodeValue(); + 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); } } return dh; diff --git a/src/com/studentersamfundet/app/ui/EventViewActivity.java b/src/com/studentersamfundet/app/ui/EventViewActivity.java index edb23f8..ff4ffe5 100644 --- a/src/com/studentersamfundet/app/ui/EventViewActivity.java +++ b/src/com/studentersamfundet/app/ui/EventViewActivity.java @@ -3,6 +3,7 @@ package com.studentersamfundet.app.ui; import android.content.Intent; import android.net.Uri; import android.os.Bundle; +import android.text.Html; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; @@ -31,10 +32,20 @@ public class EventViewActivity extends BaseDnsActivity { Button link = (Button) findViewById(R.id.event_view_link); title.setText(e.title); - description.setText(e.description); location.setText(e.location); datetime.setText(e.date); + StringBuilder sb = new StringBuilder(); + if (e.description.length() > 0) { + sb.append(""); + sb.append(e.description); + sb.append("

"); + } + if (e.text.length() > 0) { + sb.append(e.text); + } + description.setText(Html.fromHtml(sb.toString())); + if (e.id > 0) { // if id exists and seems legit link.setVisibility(View.VISIBLE); link.setOnClickListener(new OnClickListener() { diff --git a/src/com/studentersamfundet/app/ui/ProgramListActivity.java b/src/com/studentersamfundet/app/ui/ProgramListActivity.java index 61b2632..f90ba4c 100644 --- a/src/com/studentersamfundet/app/ui/ProgramListActivity.java +++ b/src/com/studentersamfundet/app/ui/ProgramListActivity.java @@ -24,6 +24,7 @@ import com.studentersamfundet.app.XmlParser; public class ProgramListActivity extends BaseDnsActivity { public static final String feedURL = "http://dl.dropbox.com/u/293287/test.xml"; + //public static final String feedURL = "http://studentersamfundet.no/"; public static final String localURL = "/data/com.studentersamfundet.app/files/dns_events"; public static FeedFetcher feed = new FeedFetcher(); public static XmlParser parser = new XmlParser();