Permalink
Browse files

Bug fixes 1-7

  • Loading branch information...
1 parent 6224f4b commit 17f4fd39cad8aeb4ab6948b4459241a8bee0070d @xirianlight xirianlight committed Mar 26, 2013
@@ -118,7 +118,7 @@
83E3AE8F16FA687A00A8F27E /* webviewpopout_shelf@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "webviewpopout_shelf@2x.png"; sourceTree = "<group>"; };
83FE37E016F76CD6000C9935 /* FlickrMapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlickrMapViewController.h; sourceTree = "<group>"; };
83FE37E116F76CD6000C9935 /* FlickrMapViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlickrMapViewController.m; sourceTree = "<group>"; };
- 8F372B0016F244C800302B80 /* MappingMashupApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MappingMashupApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 8F372B0016F244C800302B80 /* MappingMashupApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = MappingMashupApp.app; path = "Wi-Where.app"; sourceTree = BUILT_PRODUCTS_DIR; };
8F372B0316F244C800302B80 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
8F372B0516F244C800302B80 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
8F372B0716F244C800302B80 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
@@ -43,10 +43,33 @@ - (APIManager*)initWithYelpSearch:(NSString*)search andLocation:(CLLocationCoord
//0mtAebqxwAxzHVOPI_OIyQ
//David's Yelp Key
- //TROLOLOLOLOLOLO
+ //ylWkpXJFz6-ZI3PvDG519A
//ARC4Random goes in here.
- yelpAPICall = [NSString stringWithFormat:@"http://api.yelp.com/business_review_search?term=%@&lat=%f&long=%f&radius=%f&limit=%d&ywsid=xltTZDS7mgHV7wtu8MkZSg", search, latitude, longitude, radius, maxItems];
+ NSString *keyToUse = @"";
+
+ switch (arc4random()%4) {
+ case 0:
+ keyToUse = @"z8HZy2Hb2axZox05xfTW9w";
+ break;
+ case 1:
+ keyToUse = @"xltTZDS7mgHV7wtu8MkZSg";
+ break;
+ case 2:
+ keyToUse = @"xltTZDS7mgHV7wtu8MkZSg"; //Currently disabled, was Paul's key, now a dupe of case 1
+ break;
+ case 3:
+ keyToUse = @"ylWkpXJFz6-ZI3PvDG519A";
+ break;
+ default:
+ keyToUse = @"z8HZy2Hb2axZox05xfTW9w"; // Emily's Yelp Key
+ NSLog(@"Did not return a proper Yelp key, returned default on random test");
+ break;
+ }
+
+ //Eventually, add if statement here if we need it, to cycle through limited-use keys
+
+ yelpAPICall = [NSString stringWithFormat:@"http://api.yelp.com/business_review_search?term=%@&lat=%f&long=%f&radius=%f&limit=%d&ywsid=%@", search, latitude, longitude, radius, maxItems, keyToUse];
NSLog(@"%@", yelpAPICall);
@@ -83,8 +106,29 @@ - (void)searchYelpThenFlickrForDelegates
//Paul's Flickr API Key 8ee0fab323e06c0f242ddc5e43e5ef2d
//Em's Flickr API Key 90087da25a0e607ed65734c6bbd4bc01dec7b05e
//Ross Flickr API Key 4dcd4b336fc303a2d36023d3c4c1b214
+ //David FLickr API Key b4a287d18b3f7398ffb4ab9f1b961e22
+
+ NSString *flickrKeyToUse = @"";
+
+ switch (arc4random()%4) {
+ case 0:
+ flickrKeyToUse = @"90087da25a0e607ed65734c6bbd4bc01dec7b05e";
+ break;
+ case 1:
+ flickrKeyToUse = @"4dcd4b336fc303a2d36023d3c4c1b214";
+ break;
+ case 2:
+ flickrKeyToUse = @"8ee0fab323e06c0f242ddc5e43e5ef2d"; break;
+ case 3:
+ flickrKeyToUse = @"b4a287d18b3f7398ffb4ab9f1b961e22";
+ break;
+ default:
+ flickrKeyToUse = @"4dcd4b336fc303a2d36023d3c4c1b214"; // Ross' Flickr Key
+ NSLog(@"Did not return a proper Yelp key, returned default on random test");
+ break;
+ }
- flickrAPICall = [NSString stringWithFormat:@"http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=4dcd4b336fc303a2d36023d3c4c1b214&tags=%@&format=json&nojsoncallback=1&lat=%@&lon=%@&radius=0.5&per_page=1&extras=url_sq%%2C+geo", search, latitude, longitude];
+ flickrAPICall = [NSString stringWithFormat:@"http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=%@&tags=%@&format=json&nojsoncallback=1&lat=%@&lon=%@&radius=0.5&per_page=1&extras=url_sq%%2C+geo", flickrKeyToUse, search, latitude, longitude];
NSLog(@"%@", flickrAPICall);
[self searchFlickrWithLatitude:latitude andLongitude:longitude];
@@ -13,6 +13,7 @@
#import "AppDelegate.h"
#import "LocationManager.h"
#import "APIManager.h"
+#import <QuartzCore/QuartzCore.h>
#import "Annotation.h"
#import "Photo.h"
@@ -35,6 +36,7 @@ @interface FlickrMapViewController ()
__weak IBOutlet UIView *loadingOverlay;
//Just to deal with map zoom issue
BOOL isZoomedInYet;
+ __weak IBOutlet UIImageView *photoViewerUIImageView;
}
@@ -64,6 +66,8 @@ - (void)viewDidLoad
//Add refresh button to Bookmarks viewController --CURRENTLY GOES TO BOOKMARKS, NEED TO WRITE METHOD FOR THIS
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshButtonPressed)];
+ [self.navigationItem.leftBarButtonItem setEnabled:NO];
+
//Add bookmarks button to viewController
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(bookmarkButtonPressed)];
@@ -281,35 +285,47 @@ -(MKAnnotationView*)mapView:(MKMapView*)mapView viewForAnnotation:(id<MKAnnotati
//Let's set that custom image
NSURL *flickrThumbnailURL = [NSURL URLWithString:selectedAnnotation.flickrThumbnailString];
NSData *photoData = [NSData dataWithContentsOfURL:flickrThumbnailURL];
- UIImage *photoThumbnailImagePreShine = [UIImage imageWithData:photoData];
- UIImage * photoThumbnailImage = [self addImage:photoThumbnailImagePreShine toImage:[UIImage imageNamed:@"CircleShine.png"]];
- //UIImage * photoThumbnailImage = [self addImage:[UIImage imageNamed:@"CircleShine.png"] toImage:photoThumbnailImagePreShine];
- //Now mask the image
-
- dispatch_async(newQueue,^void(void)
- {
- UIImage * mask = [UIImage imageNamed:@"circleMask.png"];
- UIImage *maskedAnnotationImage = [self createMaskWith:mask onImage:photoThumbnailImage];
- dispatch_async(dispatch_get_main_queue(),^void (void)
- {
- annotationView.image = maskedAnnotationImage;
- });
-
- });
-
-
- //Add the shine - can do later
-// UIImage *backgroundImage = maskedAnnotationImage;
-// UIImage *watermarkImage = [UIImage imageNamed:@"circleMaskShine"];
+ UIImage *photoThumbnailImage = [UIImage imageWithData:photoData];
+ UIImageView *imageWithFrame = [[UIImageView alloc] initWithImage:photoThumbnailImage];
+ [imageWithFrame.layer setBorderColor: [[UIColor whiteColor] CGColor]];
+ [imageWithFrame.layer setBorderWidth: 4.0];
+ [annotationView addSubview:imageWithFrame];
+
+ //Add frame to annotation
+// annotationView.image = [UIImage imageNamed:[NSString stringWithFormat:@"F.png"]];
//
-// UIGraphicsBeginImageContext(backgroundImage.size);
-// [backgroundImage drawInRect:CGRectMake(0, 0, backgroundImage.size.width, backgroundImage.size.height)];
-// [watermarkImage drawInRect:CGRectMake(backgroundImage.size.width - watermarkImage.size.width, backgroundImage.size.height - watermarkImage.size.height, watermarkImage.size.width, watermarkImage.size.height)];
-// UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
-// UIGraphicsEndImageContext();
-
+// UIImage *frame = [UIImage imageNamed:[NSString stringWithFormat:@"F.png"];
+// UIImage *image = photoThumbnailImage;
+//
+// UIGraphicsBeginImageContext(CGSizeMake(pin.size.width, pin.size.height));
+//
+// [frame drawInRect:CGRectMake(0, 0, frame.size.width, frame.size.height)];
+// [image drawInRect:CGRectMake(4, 4, 60, 60)]; // the frame your inner image
+// //maybe you should draw the left bottom icon here,
+//
+//
+// //then set back the new image, done
+// annotationView.image = UIGraphicsGetImageFromCurrentImageContext();
+//
+// UIGraphicsEndImageContext();
+
+
+
+ annotationView.image = photoThumbnailImage;
+
+// dispatch_async(newQueue,^void(void)
+// {
+// UIImage * mask = [UIImage imageNamed:@"circleMask.png"];
+// UIImage *maskedAnnotationImage = [self createMaskWith:mask onImage:photoThumbnailImage];
+// dispatch_async(dispatch_get_main_queue(),^void (void)
+// {
+// annotationView.image = photoThumbnailImage;
+// });
+//
+// });
+
//Set the imageView inside the
- UIImageView *photoContainer = [[UIImageView alloc] initWithImage:photoThumbnailImagePreShine];
+ UIImageView *photoContainer = [[UIImageView alloc] initWithImage:photoThumbnailImage];
photoContainer.contentMode = UIViewContentModeScaleAspectFit;
@@ -324,7 +340,10 @@ -(MKAnnotationView*)mapView:(MKMapView*)mapView viewForAnnotation:(id<MKAnnotati
//Move "add bookmark" notification off-screen
- [UIView animateWithDuration:3.5 delay:2.0 options:nil animations:^(void) { loadingOverlay.alpha = 0;} completion:^(BOOL finished){}];
+ //Re-enable refresh button
+ [UIView animateWithDuration:3.5 delay:2.0 options:nil animations:^(void) { loadingOverlay.alpha = 0; } completion:^(BOOL finished){ [self.navigationItem.leftBarButtonItem setEnabled:YES];
+}];
+
// [UIView animateWithDuration:3.5 animations:^(void) {
// loadingOverlay.alpha = 0;}];
@@ -401,6 +420,14 @@ - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *
[view squishImage];
selectedAnnotation = view.annotation;
+ //Code to make the selected image show up in the photo viewer
+ NSString *photoFullSizeURLString = [selectedAnnotation.flickrThumbnailString stringByReplacingOccurrencesOfString:@"s.jpg" withString:@"n.jpg"];
+ NSURL *photoFullSizeURL = [NSURL URLWithString:photoFullSizeURLString];
+
+ NSData *photoData = [NSData dataWithContentsOfURL:photoFullSizeURL];
+ UIImage *photoFullSize = [UIImage imageWithData:photoData];
+ photoViewerUIImageView.image = photoFullSize;
+
//Note: This should break when we switch from Yelp annotations
@@ -441,6 +468,9 @@ -(void)refreshButtonPressed
{
[mapView removeAnnotations : mapView.annotations ];
[mapView removeOverlays:mapView.overlays];
+
+ [self.navigationItem.leftBarButtonItem setEnabled:NO];
+
[UIView animateWithDuration:0.5 animations:^(void) {
loadingOverlay.alpha = 1;}];
[self viewDidLoad];
@@ -46,6 +46,7 @@ - (void)viewDidLoad
self.title = @"History";
historyArray = [self allEntitiesNamed:@"Business"];
+
//testHistory = [[NSArray alloc] initWithObjects:@"History 1", @"History 2", @"History 3", nil];
@@ -122,10 +123,10 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd
//NSLog(@"Add bookmark status failed.");
}
- historyArray = [self allEntitiesNamed:@"Business"];
+ // historyArray = [self allEntitiesNamed:@"Business"];
- //bookmarkArray = [self fetchBookmarks];
+ historyArray = [self fetchBookmarks];
[tableView reloadData];
//[self removeBookmarkStatusFrom:business]
@@ -140,8 +141,11 @@ -(NSArray *)allEntitiesNamed:(NSString *)entityName
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:self.managedObjectContext];
NSError *error;
-
+ NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"viewDate" ascending:NO];
+ NSArray * sortDescriptorArray = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
fetchRequest.entity = entity;
+ [fetchRequest setSortDescriptors:sortDescriptorArray];
+
return [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
}
@@ -155,7 +159,9 @@ -(NSArray*) fetchBookmarks
NSFetchedResultsController * fetchResultsController;
//Now customize your search! We'd want to switch this to see if isBookmarked == true
- NSArray * sortDescriptors = [[NSArray alloc] initWithObjects:nil];
+ NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"viewDate" ascending:YES];
+ NSArray * sortDescriptorArray = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
+
NSPredicate * predicate = [NSPredicate predicateWithFormat:@"isBookmarked == %@", [NSNumber numberWithBool:YES]];
NSError *searchError;
@@ -171,7 +177,7 @@ -(NSArray*) fetchBookmarks
// }
//Lock and load
- [fetchRequest setSortDescriptors:sortDescriptors];
+ [fetchRequest setSortDescriptors:sortDescriptorArray];
[fetchRequest setPredicate:predicate];
[fetchRequest setEntity:entityDescription];
fetchResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
@@ -38,7 +38,7 @@ -(NSArray *)retrieveAllEntitiesNamed:(NSString *)entityName
-(void)removeVenuesOverLimit
{
- for (int i = 4; i < allHistories.count; i++) {
+ for (int i = 50; i < allHistories.count; i++) {
Business *business = [allHistories objectAtIndex:i];
[self.managedObjectContext deleteObject:business];
@@ -87,6 +87,7 @@ - (void)viewDidLoad
UIImage *photoFullSize = [UIImage imageWithData:photoData];
photoViewerUIImageView.image = photoFullSize;
+
Annotation *originAnnotation = [[Annotation alloc] initWithCoordinate:originLocationCoordinate title:originPhotoTitle subtitle:@"Your Selected Photo" urlString:originPhotoThumbnailString];
@@ -335,6 +336,7 @@ - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *
selectedBusiness.name = selectedAnnotation.name;
selectedBusiness.yelpURLString = selectedAnnotation.yelpURLString;
selectedBusiness.viewDate = selectedAnnotation.viewDate;
+ NSLog(@"Selected business view date:%@", selectedAnnotation.viewDate);
selectedBusiness.phone = selectedAnnotation.phone;
Oops, something went wrong.

0 comments on commit 17f4fd3

Please sign in to comment.