Permalink
Browse files

Working widget that displays todo items! A little ugly though

  • Loading branch information...
1 parent e0886f9 commit d23049fc904710010ff85bd94f0f46a47d40c500 @matburt committed May 6, 2010
@@ -11,6 +11,6 @@
android:layout_height="wrap_content"
android:layout_marginTop="12dip"
android:padding="10dip"
- android:gravity="center"
+ android:gravity="left"
android:text="WidgetText"/>
</LinearLayout>
@@ -55,7 +55,13 @@ public RemoteViews genUpdateDisplay(Context context) {
String storageMode = this.getStorageLocation(context);
OrgFileParser ofp = new OrgFileParser(allOrgList, storageMode);
ofp.parse();
- updateViews.setTextViewText(R.id.message, "Everything worked");
+ Node agendaNode = ofp.rootNode.findChildNode("agendas.org");
+ Node todoNode = agendaNode.findChildNode("ToDo: ALL");
+ String widgetBuffer = "";
+ for (int idx = 0; idx < todoNode.subNodes.size(); idx++) {
+ widgetBuffer = widgetBuffer + todoNode.subNodes.get(idx).nodeName + "\n";
+ }
+ updateViews.setTextViewText(R.id.message, widgetBuffer);
return updateViews;
}
@@ -2,6 +2,8 @@
import java.util.ArrayList;
import java.util.Date;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
class Node {
@@ -10,12 +12,12 @@
HEADER, HEADING, COMMENT, DATA
}
+ ArrayList<Node> subNodes = new ArrayList<Node>();
+ ArrayList<String> tags = new ArrayList<String>();
String nodeName = "";
String todo = "";
NodeType nodeType;
- ArrayList<Node> subNodes = new ArrayList<Node>();
String nodePayload = "";
- ArrayList<String> tags = new ArrayList<String>();
Date schedule = null;
Date deadline = null;
@@ -24,6 +26,16 @@
nodeType = ntype;
}
+ Node findChildNode(String regex) {
+ Pattern findNodePattern = Pattern.compile(regex);
+ for (int idx = 0; idx < this.subNodes.size(); idx++) {
+ if (findNodePattern.matcher(this.subNodes.get(idx).nodeName).matches()) {
+ return this.subNodes.get(idx);
+ }
+ }
+ return null;
+ }
+
void addPayload(String npayload) {
this.nodePayload += npayload + "\n";
}

0 comments on commit d23049f

Please sign in to comment.