Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Obkircher Jakob committed Nov 19, 2010
1 parent c5c0951 commit de93bbe
Show file tree
Hide file tree
Showing 12 changed files with 64,346 additions and 58,695 deletions.
6 changes: 3 additions & 3 deletions Classes/ARViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/> */
#import <UIKit/UIKit.h>

#import "MarkerView.h"
#import <CoreLocation/CoreLocation.h>

#import "ARCoordinate.h"

@protocol ARViewDelegate

- (UIView *)viewForCoordinate:(ARCoordinate *)coordinate;
- (MarkerView *)viewForCoordinate:(ARCoordinate *)coordinate;

@end

Expand Down Expand Up @@ -54,7 +54,7 @@

NSTimer *_updateTimer;

UIView *ar_overlayView;
MarkerView *ar_overlayView;

UILabel *ar_debugView;

Expand Down
7 changes: 7 additions & 0 deletions Classes/ARViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,20 @@ - (BOOL)viewportContainsCoordinate:(ARCoordinate *)coordinate {
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
NSLog(@"ROTATE");
return (interfaceOrientation == UIInterfaceOrientationPortrait)||(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
-(void)stopListening{
if(self.locationManager != nil){
[locationManager stopUpdatingHeading];
}
}


-(void)markerClick:(id)sender{
NSLog(@"MARKER");
}

- (void)startListening {

//start our heading readings and our accelerometer readings.
Expand Down
78 changes: 42 additions & 36 deletions Classes/JsonHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,53 +41,59 @@ -(NSMutableArray*)processWikipediaJSONData: (NSString*) jsonData{
return ret;
}
-(NSMutableArray*)processMixareJSONData: (NSString*) jsonData{
NSDictionary* data = [jsonData JSONValue];
NSMutableArray* ret = [[NSMutableArray alloc]init];
NSArray* geonames = [data objectForKey:@"results"];
for(NSDictionary *geoname in geonames){
[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:[geoname objectForKey:@"title"],kTitleKey, [geoname objectForKey:@"webpage"],kUrlKey,[geoname objectForKey:@"lng"],kLonKey,[geoname objectForKey:@"lat"],kLatKey,[geoname objectForKey:@"elevation"],kAltKey,@"MIXARE",kSourceKey, nil]];
}
return ret;
if(! [jsonData isEqualToString:@""]){
NSDictionary* data = [jsonData JSONValue];
NSMutableArray* ret = [[NSMutableArray alloc]init];
NSArray* geonames = [data objectForKey:@"results"];
for(NSDictionary *geoname in geonames){
[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:[geoname objectForKey:@"title"],kTitleKey, [geoname objectForKey:@"webpage"],kUrlKey,[geoname objectForKey:@"lng"],kLonKey,[geoname objectForKey:@"lat"],kLatKey,[geoname objectForKey:@"elevation"],kAltKey,@"MIXARE",kSourceKey, nil]];
}
return ret;
}else return nil;
}

-(NSMutableArray*)processTwitterJSONData: (NSString*) jsonData{
NSDictionary * data = [jsonData JSONValue];
NSMutableArray* ret = [[NSMutableArray alloc]init];
NSArray* tweets = [data objectForKey:@"results"];
float height = 8000.0;
for(NSDictionary *tweet in tweets){
[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:[tweet objectForKey:@"from_user"],kUserKey,[tweet objectForKey:@"text"],kTitleKey,[NSString stringWithFormat:@"http://twitter.com/%@",[tweet objectForKey:@"from_user"]],kUrlKey, @"TWITTER",kSourceKey,nil]];
[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:[tweet objectForKey:@"from_user"],kUserKey,[tweet objectForKey:@"text"],kTitleKey,[NSString stringWithFormat:@"http://twitter.com/%@",[tweet objectForKey:@"from_user"]],kUrlKey, @"TWITTER",kSourceKey,[NSString stringWithFormat:@"%f",height],kAltKey,nil]];
height += 1000;
}
return ret;
}

-(NSMutableArray*)processBuzzJSONData: (NSString*) jsonData{
NSDictionary * data = [jsonData JSONValue];
NSMutableArray* ret = [[NSMutableArray alloc]init];
NSDictionary* msgs = [data objectForKey:@"data"];
NSArray* items = [msgs objectForKey:@"items"];
float height = 8000.0;
for(NSDictionary *msg in items){
NSArray * splittedGeoCode = [[msg objectForKey:@"geocode"] componentsSeparatedByString:@" "];

NSString* lat = [splittedGeoCode objectAtIndex:0];
NSString* lng = [splittedGeoCode objectAtIndex:1];
NSLog(@"%@:%@",lat,lng);
NSDictionary * links = [msg objectForKey:@"links"];
NSArray * alternate = [links objectForKey:@"alternate"];
NSDictionary *href=[alternate objectAtIndex:0];
NSString * link = [href objectForKey:@"href"];
NSString * title = [msg objectForKey:@"title"];
NSArray * words = [title componentsSeparatedByString:@" "];
NSMutableString * finalText = [[NSMutableString alloc]init];
for(int i=0;i <[words count]; i++){
[finalText appendFormat:@" %@",[words objectAtIndex:i]];
if(i % 3 ==0 && i !=0){
[finalText appendString: @"\n"];
}
}
height += 1000;
[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:lat,kLatKey,lng,kLonKey,title,kTitleKey, link,kUrlKey,@"BUZZ",kSourceKey,[NSString stringWithFormat:@"%f",height],kAltKey, nil]];
}
return ret;
if(jsonData != nil){
NSDictionary * data = [jsonData JSONValue];
NSMutableArray* ret = [[NSMutableArray alloc]init];
NSDictionary* msgs = [data objectForKey:@"data"];
NSArray* items = [msgs objectForKey:@"items"];
float height = 8000.0;
for(NSDictionary *msg in items){
NSArray * splittedGeoCode = [[msg objectForKey:@"geocode"] componentsSeparatedByString:@" "];

NSString* lat = [splittedGeoCode objectAtIndex:0];
NSString* lng = [splittedGeoCode objectAtIndex:1];
NSLog(@"%@:%@",lat,lng);
NSDictionary * links = [msg objectForKey:@"links"];
NSArray * alternate = [links objectForKey:@"alternate"];
NSDictionary *href=[alternate objectAtIndex:0];
NSString * link = [href objectForKey:@"href"];
NSString * title = [msg objectForKey:@"title"];
NSArray * words = [title componentsSeparatedByString:@" "];
NSMutableString * finalText = [[NSMutableString alloc]init];
for(int i=0;i <[words count]; i++){
[finalText appendFormat:@" %@",[words objectAtIndex:i]];
if(i % 3 ==0 && i !=0){
[finalText appendString: @"\n"];
}
}
height += 1000;
[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:lat,kLatKey,lng,kLonKey,title,kTitleKey, link,kUrlKey,@"BUZZ",kSourceKey,[NSString stringWithFormat:@"%f",height],kAltKey, nil]];
}
return ret;
}return nil;
}
@end
20 changes: 3 additions & 17 deletions Classes/ListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@
#import "ListViewController.h"
#import "WebViewController.h"

#define kTextFieldWidth 180.0
#define kViewTag 1
#define kLeftMargin 100.0
#define kTopMargin 20.0
#define kRightMargin 20.0
#define kTweenMargin 11.0

#define kTextFieldHeight 30.0
static NSString *kSectionTitleKey = @"sectionTitleKey";


@implementation ListViewController
@synthesize dataSourceArray= source;
Expand Down Expand Up @@ -81,8 +71,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
}

// to determine specific row height for each cell, override this.
// In this example, each row is determined by its subviews that are embedded.
//

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return ([indexPath row] == 0) ? 60.0 : 60.0;
Expand All @@ -92,14 +81,11 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
//
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = nil;
//NSUInteger row = [indexPath row];
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil] autorelease];
if(source != nil){
cell.textLabel.text = [[source objectAtIndex:indexPath.row]valueForKey:@"title"];
cell.detailTextLabel.text = [[source objectAtIndex:indexPath.row]valueForKey:@"sum"];
}else{
//
}
}
return cell;
}
#pragma mark -
Expand All @@ -109,7 +95,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"in select row");
WebViewController *targetViewController = [[WebViewController alloc] initWithNibName:@"WebView" bundle:nil];
if([[[source objectAtIndex:indexPath.row]valueForKey:@"source"] isEqualToString:@"BUZZ"]){
if([[[source objectAtIndex:indexPath.row]valueForKey:@"source"] isEqualToString:@"BUZZ"] || [[[source objectAtIndex:indexPath.row]valueForKey:@"source"] isEqualToString:@"TWITTER"]){
targetViewController.url = [NSString stringWithFormat:@"%@",[[source objectAtIndex:indexPath.row]valueForKey:@"url"]];
}else{
targetViewController.url = [NSString stringWithFormat:@"http://%@",[[source objectAtIndex:indexPath.row]valueForKey:@"url"]];
Expand Down
4 changes: 3 additions & 1 deletion Classes/MixareAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import "ARGeoViewController.h"
#import "JsonHandler.h"
#import "MapViewController.h"
#import "MarkerView.h"
@interface MixareAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate,ARViewDelegate, CLLocationManagerDelegate>{
UIWindow *window;
UIButton *_closeButton;
Expand All @@ -36,7 +37,7 @@
CMMotionManager *motionManager;
ListViewController * _listViewController;
MapViewController * _mapViewController;
ARGeoViewController *viewController;
ARGeoViewController *augViewController;
NSMutableArray * _data;
JsonHandler * jHandler;
UISlider * _slider;
Expand All @@ -61,4 +62,5 @@
-(void)mapData;
-(void)downloadData;
-(void) initControls;
-(BOOL)checkIfDataSourceIsEanabled: (NSString *)source;
@end
Loading

0 comments on commit de93bbe

Please sign in to comment.