forked from aranguren/demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit eb403a7
Showing
104 changed files
with
2,048 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
381 changes: 381 additions & 0 deletions
381
EarthquakeTable/EarthquakeTable.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
EarthquakeTable/EarthquakeTable.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// EQAppDelegate.h | ||
// EarthquakeTable | ||
// | ||
// Created by Mano Marks on 2/28/13. | ||
// Copyright (c) 2013 Google. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import <GoogleMaps/GoogleMaps.h> | ||
|
||
@interface EQAppDelegate : UIResponder <UIApplicationDelegate> | ||
|
||
@property (strong, nonatomic) UIWindow *window; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// EQAppDelegate.m | ||
// EarthquakeTable | ||
// | ||
// Created by Mano Marks on 2/28/13. | ||
// Copyright (c) 2013 Google. All rights reserved. | ||
// | ||
|
||
#import "EQAppDelegate.h" | ||
|
||
@implementation EQAppDelegate | ||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | ||
{ | ||
[GMSServices provideAPIKey:@"AIzaSyDvBVo8rd0YXIUwSE0aUCyESyRSA_sKY_E"]; | ||
|
||
return YES; | ||
} | ||
|
||
- (void)applicationWillResignActive:(UIApplication *)application | ||
{ | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | ||
} | ||
|
||
- (void)applicationDidEnterBackground:(UIApplication *)application | ||
{ | ||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
} | ||
|
||
- (void)applicationWillEnterForeground:(UIApplication *)application | ||
{ | ||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. | ||
} | ||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application | ||
{ | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
} | ||
|
||
- (void)applicationWillTerminate:(UIApplication *)application | ||
{ | ||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// EQTableViewController.h | ||
// EarthquakeTable | ||
// | ||
// Created by Mano Marks on 3/4/13. | ||
// Copyright (c) 2013 Google. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface EQTableViewController : UITableViewController | ||
@property (nonatomic, strong) IBOutlet UILabel *quakeLabel; | ||
@property (nonatomic, strong) NSString *quakeName; | ||
@property (nonatomic, strong) IBOutlet UITableView *tableView; | ||
@property (nonatomic, strong) NSData* data; | ||
@property (nonatomic, strong) NSDictionary* json; | ||
|
||
@end |
141 changes: 141 additions & 0 deletions
141
EarthquakeTable/EarthquakeTable/EQTableViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
// | ||
// EQTableViewController.m | ||
// EarthquakeTable | ||
// | ||
// Created by Mano Marks on 3/4/13. | ||
// Copyright (c) 2013 Google. All rights reserved. | ||
// | ||
#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) //1 | ||
#define kUSGSEarthQuakes [NSURL URLWithString:@"http://earthquake.usgs.gov/earthquakes/feed/geojson/all/hour"] | ||
|
||
#import "EQViewController.h" | ||
#import "EQTableViewController.h" | ||
#import <GoogleMaps/GoogleMaps.h> | ||
|
||
@interface EQTableViewController (){ | ||
NSMutableArray *quakeArray; | ||
NSMutableArray *markerArray; | ||
} | ||
@end | ||
|
||
@implementation EQTableViewController | ||
|
||
- (id)initWithStyle:(UITableViewStyle)style | ||
{ | ||
self = [super initWithStyle:style]; | ||
if (self) { | ||
// Custom initialization | ||
} | ||
return self; | ||
} | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
[self fetchData]; | ||
} | ||
-(void)fetchData | ||
{ | ||
quakeArray = [[NSMutableArray alloc]initWithObjects: nil]; | ||
markerArray = [[NSMutableArray alloc]initWithObjects: nil]; | ||
dispatch_async(kBgQueue, ^{ | ||
_data = [NSData dataWithContentsOfURL: | ||
kUSGSEarthQuakes]; | ||
[self performSelectorOnMainThread:@selector(fetchedData:) | ||
withObject:_data waitUntilDone:YES]; | ||
}); | ||
|
||
} | ||
- (void)fetchedData:(NSData *)responseData { | ||
|
||
quakeArray = [[NSMutableArray alloc] initWithCapacity:100]; | ||
|
||
NSError* error; | ||
_json = [NSJSONSerialization | ||
JSONObjectWithData:responseData | ||
|
||
options:kNilOptions | ||
error:&error]; | ||
|
||
NSArray* latestEarthquakes = [_json objectForKey:@"features"]; //2 | ||
for(int i=0;i<[latestEarthquakes count];i++){ | ||
NSDictionary* earthquake = [latestEarthquakes objectAtIndex:i]; | ||
NSDictionary* properties = [earthquake objectForKey:@"properties"]; | ||
NSDictionary* geometry = [earthquake objectForKey:@"geometry"]; | ||
NSString *place = [properties objectForKey:@"place"]; | ||
[quakeArray addObject:place]; | ||
|
||
NSArray* coordinates = [geometry objectForKey:@"coordinates"]; | ||
double latitude = [[coordinates objectAtIndex:1] doubleValue]; | ||
double longitude = [[coordinates objectAtIndex:0] doubleValue]; | ||
NSString *magnitude = [[properties objectForKey:@"mag"] stringValue]; | ||
GMSMarkerOptions *options = [[GMSMarkerOptions alloc] init]; | ||
options.snippet = magnitude; | ||
options.title = place; | ||
options.position = CLLocationCoordinate2DMake(latitude,longitude); | ||
[markerArray addObject:options]; | ||
|
||
} | ||
|
||
[[self tableView] reloadData]; | ||
|
||
|
||
} | ||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | ||
if ([segue.identifier isEqualToString:@"showEarthQuakeMarker"]) { | ||
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; | ||
EQViewController *destViewController = segue.destinationViewController; | ||
destViewController.options = [markerArray objectAtIndex:indexPath.row]; | ||
} | ||
|
||
} | ||
|
||
- (void)didReceiveMemoryWarning | ||
{ | ||
[super didReceiveMemoryWarning]; | ||
} | ||
|
||
|
||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView | ||
{ | ||
return 1; | ||
} | ||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | ||
{ | ||
return [quakeArray count]; | ||
} | ||
|
||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"MapCell"]; | ||
|
||
if(!cell) | ||
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MapCell"]; | ||
|
||
NSString* val = [quakeArray objectAtIndex:indexPath.row]; | ||
cell.textLabel.text = val; | ||
|
||
return cell; | ||
|
||
} | ||
|
||
|
||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
// Navigation logic may go here. Create and push another view controller. | ||
/* | ||
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; | ||
// ... | ||
// Pass the selected object to the new view controller. | ||
[self.navigationController pushViewController:detailViewController animated:YES]; | ||
*/ | ||
} | ||
|
||
|
||
|
||
-(IBAction)instructions { | ||
[self fetchData]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// EQViewController.h | ||
// EarthquakeTable | ||
// | ||
// Created by Mano Marks on 2/28/13. | ||
// Copyright (c) 2013 Google. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import <GoogleMaps/GoogleMaps.h> | ||
|
||
@interface EQViewController : UIViewController | ||
@property (nonatomic, assign) IBOutlet GMSMarkerOptions *options; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// EQViewController.m | ||
// EarthquakeTable | ||
// | ||
// Created by Mano Marks on 2/28/13. | ||
// Copyright (c) 2013 Google. All rights reserved. | ||
// | ||
|
||
#import "EQViewController.h" | ||
#import <GoogleMaps/GoogleMaps.h> | ||
|
||
@interface EQViewController () | ||
|
||
@end | ||
|
||
@implementation EQViewController | ||
@synthesize options; | ||
GMSMapView *mapView_; | ||
|
||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
[mapView_ addMarkerWithOptions:options]; | ||
CLLocationDegrees latitude = options.position.latitude; | ||
CLLocationDegrees longitude = options.position.longitude; | ||
GMSCameraPosition *cameraNew = [GMSCameraPosition cameraWithLatitude:latitude | ||
longitude:longitude | ||
zoom:6]; | ||
mapView_.camera = cameraNew; | ||
} | ||
|
||
- (void)didReceiveMemoryWarning | ||
{ | ||
[super didReceiveMemoryWarning]; | ||
// Dispose of any resources that can be recreated. | ||
} | ||
- (void)loadView { | ||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:0 | ||
longitude:0 | ||
zoom:5]; | ||
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; | ||
mapView_.myLocationEnabled = NO; | ||
self.view = mapView_; | ||
|
||
} | ||
|
||
|
||
@end |
41 changes: 41 additions & 0 deletions
41
EarthquakeTable/EarthquakeTable/EarthquakeTable-Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.google.${PRODUCT_NAME:rfc1034identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>UIMainStoryboardFile</key> | ||
<string>MainStoryboard</string> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>armv7</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations~ipad</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
</dict> | ||
</plist> |
14 changes: 14 additions & 0 deletions
14
EarthquakeTable/EarthquakeTable/EarthquakeTable-Prefix.pch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Prefix header for all source files of the 'EarthquakeTable' target in the 'EarthquakeTable' project | ||
// | ||
|
||
#import <Availability.h> | ||
|
||
#ifndef __IPHONE_5_0 | ||
#warning "This project uses features only available in iOS SDK 5.0 and later." | ||
#endif | ||
|
||
#ifdef __OBJC__ | ||
#import <UIKit/UIKit.h> | ||
#import <Foundation/Foundation.h> | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* Localized versions of Info.plist keys */ | ||
|
Oops, something went wrong.