summaryrefslogtreecommitdiff
path: root/data/iphone-java/HelloJava.app/HelloJava.java
diff options
context:
space:
mode:
Diffstat (limited to 'data/iphone-java/HelloJava.app/HelloJava.java')
-rw-r--r--data/iphone-java/HelloJava.app/HelloJava.java117
1 files changed, 62 insertions, 55 deletions
diff --git a/data/iphone-java/HelloJava.app/HelloJava.java b/data/iphone-java/HelloJava.app/HelloJava.java
index b33f9b64c..4face9dd7 100644
--- a/data/iphone-java/HelloJava.app/HelloJava.java
+++ b/data/iphone-java/HelloJava.app/HelloJava.java
@@ -18,12 +18,10 @@ private UIWindow window;
private static class Contact {
public String first;
public String last;
- public UITableCell cell;
public Contact(String first, String last) {
this.first = first;
this.last = last;
- this.cell = null;
}
public String getName() {
@@ -44,39 +42,77 @@ public static class Section {
}
}
-private ArrayList<Contact> contacts_ = new ArrayList<Contact>();
-private ArrayList<Section> sections_ = new ArrayList<Section>();
+private ArrayList<Contact> contacts_;
+private ArrayList<Section> sections_;
+
+@Message int numberOfSectionsInSectionList$(UISectionList list) {
+ return sections_.size();
+}
+
+@Message String sectionList$titleForSection$(UISectionList list, int section) {
+ return sections_.get(section).title;
+}
+
+@Message int sectionList$rowForSection$(UISectionList list, int section) {
+ return sections_.get(section).row;
+}
+
+@Message int numberOfRowsInTable$(UITable table) {
+ return contacts_.size();
+}
+
+@Message UITableCell table$cellForRow$column$reusing$(UITable table, int row, UITableColumn col, UITableCell reusing) {
+ Contact contact = contacts_.get(row);
+
+ UIImageAndTextTableCell cell;
+ if (reusing != null)
+ cell = (UIImageAndTextTableCell) reusing;
+ else
+ cell = (UIImageAndTextTableCell) new UIImageAndTextTableCell().init();
+
+ cell.setTitle$(contact.getName());
+ return cell;
+}
+
+@Message public byte table$canSelectRow$(UITable table, int row) {
+ return NO;
+}
@Message public void applicationDidFinishLaunching$(Object unused)
throws Exception
{
+ contacts_ = new ArrayList<Contact>();
+ sections_ = new ArrayList<Section>();
+
SQLite.Database ab = new SQLite.Database();
ab.open(userHomeDirectory().toString() + "/Library/AddressBook/AddressBook.sqlitedb", 0666); try {
SQLite.Stmt st = ab.prepare("select first, last from ABPerson where first is not null order by first"); try {
while (st.step())
- contacts_.add(new Contact(st.column_string(0), st.column_string(1)));
+ contacts_.add(new Contact(
+ st.column_string(0),
+ st.column_string(1)
+ ));
} finally { st.close(); }
} finally { ab.close(); }
CGRect outer = UIHardware.fullScreenApplicationContentRect();
- CGRect inner = outer.clone();
- inner.origin.x = inner.origin.y = 0;
+ window = new UIWindow().initWithContentRect$(outer);
- window = new UIWindow().initWithContentRect$(inner);
window.orderFront$(this);
window.makeKey$(this);
window._setHidden$(NO);
+ CGRect inner = window.bounds();
CGSize navsize = UINavigationBar.defaultSize();
- UINavigationBar navbar = new UINavigationBar().initWithFrame$(new CGRect(0, 0, inner.size.width, navsize.height));
- navbar.setBarStyle$(1);
- navbar.showButtonsWithLeftTitle$rightTitle$leftBack$("Run GC", null, YES);
+ CGRect navrect = new CGRect(0, 0, inner.size.width, navsize.height);
- navbar.setDelegate$(new NSObject() {
- @Message void navigationBar$buttonClicked$(UINavigationBar navbar, int button) {
- navbar.showButtonsWithLeftTitle$rightTitle$leftBack$("I was clicked!", null, YES);
- }
- }.init());
+ UIView view = new UIView().initWithFrame$(inner);
+ window.setContentView$(view);
+
+ UINavigationBar navbar = new UINavigationBar().initWithFrame$(navrect);
+ view.addSubview$(navbar);
+
+ navbar.setBarStyle$(1);
UINavigationItem navitem = new UINavigationItem().initWithTitle$("Contact List");
navbar.pushNavigationItem$(navitem);
@@ -88,54 +124,25 @@ private ArrayList<Section> sections_ = new ArrayList<Section>();
if (letter != now) {
letter = now;
sections_.add(new Section(
- i, new String(new char[] {now})
+ i,
+ new String(new char[] {now})
));
}
}
- UISectionList seclist = new UISectionList().initWithFrame$(new CGRect(0, navsize.height, inner.size.width, inner.size.height - navsize.height));
-
- seclist.setDataSource$(new NSObject() {
- @Message int numberOfSectionsInSectionList$(UISectionList list) {
- return sections_.size();
- }
+ CGRect lower = new CGRect(0, navsize.height, inner.size.width, inner.size.height - navsize.height);
+ UISectionList list = new UISectionList().initWithFrame$(lower);
+ view.addSubview$(list);
- @Message String sectionList$titleForSection$(UISectionList list, int section) {
- return sections_.get(section).title;
- }
+ UITableColumn col = new UITableColumn().initWithTitle$identifier$width$("Name", "name", 320);
- @Message int sectionList$rowForSection$(UISectionList list, int section) {
- return sections_.get(section).row;
- }
-
- @Message int numberOfRowsInTable$(UITable table) {
- return contacts_.size();
- }
-
- @Message UITableCell table$cellForRow$column$(UITable table, int row, UITableColumn col) {
- Contact contact = contacts_.get(row);
- if (contact.cell != null)
- return contact.cell;
- UIImageAndTextTableCell cell = (UIImageAndTextTableCell) new UIImageAndTextTableCell().init();
- cell.setTitle$(contact.getName());
- contact.cell = cell;
- return cell;
- }
- }.init());
-
- seclist.reloadData();
-
- UITableColumn col = new UITableColumn().initWithTitle$identifier$width$("Name", "name", 320.0f);
-
- UITable table = (UITable) seclist.table();
+ UITable table = (UITable) list.table();
table.setSeparatorStyle$(1);
table.addTableColumn$(col);
+ table.setReusesTableCells$(YES);
- UIView view = new UIView().initWithFrame$(inner);
- view.addSubview$(navbar);
- view.addSubview$(seclist);
-
- window.setContentView$(view);
+ list.setDataSource$(this);
+ list.reloadData();
AVController controller = new AVController().init();
CharSequence wavfile = (CharSequence) ((NSBundle) NSBundle.mainBundle()).pathForResource$ofType$("start", "wav");