Archived
Cleanup.
This commit is contained in:
1 parent
5da4cffc43
commit
832c6ed7c4
5 files changed
+43
-41
No files matched your search
+2
-2
@@ -8,14 +8,14 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
|
||||
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<activity android:name=".DnsActivity"
|
||||
<activity android:name=".ui.DnsActivity"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".ProgramList"></activity>
|
||||
<activity android:name=".ui.ProgramList"></activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -1,29 +1,24 @@
|
||||
package com.studentersamfundet.app;
|
||||
|
||||
public class DataHandler {
|
||||
Event events;
|
||||
import java.util.LinkedList;
|
||||
|
||||
void insert(String id, String title, String description, String date, String location, String category) {
|
||||
public class DataHandler {
|
||||
private LinkedList<Event> events = new LinkedList<Event>();
|
||||
|
||||
public void insert(String id, String title, String description, String date, String location, String category) {
|
||||
int intId = Integer.parseInt(id);
|
||||
if (get(intId) != null)
|
||||
return;
|
||||
|
||||
Event e = new Event(intId, title, description, date, location, category);
|
||||
|
||||
if (events == null)
|
||||
events = e;
|
||||
else {
|
||||
Event tmp = events;
|
||||
while (tmp.next != null)
|
||||
tmp = tmp.next;
|
||||
tmp.next = e;
|
||||
}
|
||||
events.add(e);
|
||||
}
|
||||
|
||||
Event get(int id) {
|
||||
Event e = events;
|
||||
while (e != null && e.id != id)
|
||||
e = e.next;
|
||||
return e;
|
||||
public Event get(int id) {
|
||||
for (Event e : events) {
|
||||
if (e.id == id)
|
||||
return e;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,13 @@ import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class XmlParser {
|
||||
public static DataHandler dh;
|
||||
private static DataHandler dh;
|
||||
|
||||
public XmlParser() {
|
||||
dh = new DataHandler();
|
||||
}
|
||||
|
||||
DataHandler parse(NodeList itemNodes) {
|
||||
public DataHandler parse(NodeList itemNodes) {
|
||||
String id = "";
|
||||
String title = "";
|
||||
String description = "";
|
||||
@@ -36,28 +36,28 @@ public class XmlParser {
|
||||
NodeList categoryNodes = (itemElement).getElementsByTagName("category");
|
||||
|
||||
// Convert a Node into an Element.
|
||||
Element idElement = (Element) idNodes.item(0);
|
||||
Element titleElement = (Element) titleNodes.item(0);
|
||||
Element descriptionElement = (Element) descriptionNodes.item(0);
|
||||
Element dateElement = (Element) dateNodes.item(0);
|
||||
Element locationElement = (Element) locationNodes.item(0);
|
||||
Element categoryElement = (Element) categoryNodes.item(0);
|
||||
Node idElement = idNodes.item(0);
|
||||
Node titleElement = titleNodes.item(0);
|
||||
Node descriptionElement = descriptionNodes.item(0);
|
||||
Node dateElement = dateNodes.item(0);
|
||||
Node locationElement = locationNodes.item(0);
|
||||
Node categoryElement = categoryNodes.item(0);
|
||||
|
||||
// Get all the child nodes.
|
||||
NodeList idTextNodes = ((Node) idElement).getChildNodes();
|
||||
NodeList titleTextNodes = ((Node) titleElement).getChildNodes();
|
||||
NodeList descriptionTextNodes = ((Node) descriptionElement).getChildNodes();
|
||||
NodeList dateTextNodes = ((Node) dateElement).getChildNodes();
|
||||
NodeList locationTextNodes = ((Node) locationElement).getChildNodes();
|
||||
NodeList categoryTextNodes = ((Node) categoryElement).getChildNodes();
|
||||
NodeList idTextNodes = idElement.getChildNodes();
|
||||
NodeList titleTextNodes = titleElement.getChildNodes();
|
||||
NodeList descriptionTextNodes = descriptionElement.getChildNodes();
|
||||
NodeList dateTextNodes = dateElement.getChildNodes();
|
||||
NodeList locationTextNodes = locationElement.getChildNodes();
|
||||
NodeList categoryTextNodes = categoryElement.getChildNodes();
|
||||
|
||||
// Retrieve the text.
|
||||
id = ((Node) idTextNodes.item(0)).getNodeValue();
|
||||
title = ((Node) titleTextNodes.item(0)).getNodeValue();
|
||||
description = ((Node) descriptionTextNodes.item(0)).getNodeValue();
|
||||
date = ((Node) dateTextNodes.item(0)).getNodeValue();
|
||||
location = ((Node) locationTextNodes.item(0)).getNodeValue();
|
||||
category = ((Node) categoryTextNodes.item(0)).getNodeValue();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -1,7 +1,12 @@
|
||||
package com.studentersamfundet.app;
|
||||
package com.studentersamfundet.app.ui;
|
||||
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.studentersamfundet.app.DataHandler;
|
||||
import com.studentersamfundet.app.FeedFetcher;
|
||||
import com.studentersamfundet.app.R;
|
||||
import com.studentersamfundet.app.XmlParser;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
package com.studentersamfundet.app;
|
||||
package com.studentersamfundet.app.ui;
|
||||
|
||||
import com.studentersamfundet.app.R;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.os.Bundle;
|
||||
Reference in new issue
Block a user