summaryrefslogtreecommitdiff
path: root/navit/iphone/downloader/Classes/RootViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'navit/iphone/downloader/Classes/RootViewController.m')
-rw-r--r--navit/iphone/downloader/Classes/RootViewController.m175
1 files changed, 175 insertions, 0 deletions
diff --git a/navit/iphone/downloader/Classes/RootViewController.m b/navit/iphone/downloader/Classes/RootViewController.m
new file mode 100644
index 00000000..2be6674f
--- /dev/null
+++ b/navit/iphone/downloader/Classes/RootViewController.m
@@ -0,0 +1,175 @@
+//
+// RootViewController.m
+// Downloader
+//
+// Created by Nick Geoghegan on 09/08/2011.
+// Copyright 2011 Navit Project. All rights reserved.
+//
+
+#import "RootViewController.h"
+#import "DownloaderDetailViewController.h"
+#import "DownloaderConstants.h"
+
+@implementation RootViewController
+
+@synthesize locations=locations_;
+
+#pragma mark -
+#pragma mark View lifecycle
+
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+
+ NSString *path = [[NSBundle mainBundle] pathForResource:@"LocationsArray" ofType:@"plist"];
+ locations_ = [[NSMutableArray alloc] initWithContentsOfFile:path];
+ // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
+ // self.navigationItem.rightBarButtonItem = self.editButtonItem;
+}
+
+
+/*
+- (void)viewWillAppear:(BOOL)animated {
+ [super viewWillAppear:animated];
+}
+*/
+/*
+- (void)viewDidAppear:(BOOL)animated {
+ [super viewDidAppear:animated];
+}
+*/
+/*
+- (void)viewWillDisappear:(BOOL)animated {
+ [super viewWillDisappear:animated];
+}
+*/
+/*
+- (void)viewDidDisappear:(BOOL)animated {
+ [super viewDidDisappear:animated];
+}
+*/
+
+/*
+ // Override to allow orientations other than the default portrait orientation.
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+ // Return YES for supported orientations.
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
+}
+ */
+
+
+#pragma mark -
+#pragma mark Table view data source
+
+// Customize the number of sections in the table view.
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+ return 1;
+}
+
+
+// Customize the number of rows in the table view.
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+ return [self.locations count] ;
+}
+
+
+// Customize the appearance of table view cells.
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+
+ static NSString *CellIdentifier = @"Cell";
+
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ if (cell == nil) {
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+ }
+
+ // Configure the cell.
+
+ cell.textLabel.text = [[self.locations objectAtIndex:indexPath.row] objectForKey:NAME_KEY];
+
+ //Makes the fancy arrows to the left of the region being downloaded (e.g. "Ireland > " )
+ cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
+ return cell;
+}
+
+
+/*
+// Override to support conditional editing of the table view.
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
+ // Return NO if you do not want the specified item to be editable.
+ return YES;
+}
+*/
+
+
+/*
+// Override to support editing the table view.
+- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
+
+ if (editingStyle == UITableViewCellEditingStyleDelete) {
+ // Delete the row from the data source.
+ [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
+ }
+ else if (editingStyle == UITableViewCellEditingStyleInsert) {
+ // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
+ }
+}
+*/
+
+
+/*
+// Override to support rearranging the table view.
+- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
+}
+*/
+
+
+/*
+// Override to support conditional rearranging of the table view.
+- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
+ // Return NO if you do not want the item to be re-orderable.
+ return YES;
+}
+*/
+
+
+#pragma mark -
+#pragma mark Table view delegate
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+
+
+ DownloaderDetailViewController *detailViewController = [[DownloaderDetailViewController alloc] initWithNibName:@"DownloaderDetailViewController" bundle:nil];
+ // ...
+ // Pass the selected object to the new view controller.
+ detailViewController.locationName = [self.locations objectAtIndex:indexPath.row];
+ [self.navigationController pushViewController:detailViewController animated:YES];
+ [DownloaderDetailViewController release];
+
+}
+
+
+#pragma mark -
+#pragma mark Memory management
+
+- (void)didReceiveMemoryWarning {
+ // Releases the view if it doesn't have a superview.
+ [super didReceiveMemoryWarning];
+
+ // Relinquish ownership any cached data, images, etc that aren't in use.
+}
+
+- (void)viewDidUnload {
+ // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
+ // For example: self.myOutlet = nil;
+}
+
+
+- (void)dealloc {
+ [locations_ release];
+ [super dealloc];
+}
+
+
+@end
+