Skip to content

Commit

Permalink
merged warrenm's bump and twitter code
Browse files Browse the repository at this point in the history
  • Loading branch information
airportyh committed Sep 4, 2010
2 parents 26b4c18 + abd9f23 commit d6425c2
Show file tree
Hide file tree
Showing 20 changed files with 2,420 additions and 549 deletions.
6 changes: 6 additions & 0 deletions Classes/AttendeeListViewController.h
Expand Up @@ -8,15 +8,21 @@

#import <UIKit/UIKit.h>

extern NSString *AppUserRegistrantIDKey;

@interface AttendeeListViewController : UITableViewController {
NSMutableArray *attendees;
NSDictionary *dictRegistrant;
NSMutableData *responseData;
UIImage *presenterIcon;
UIActivityIndicatorView *progressInd;
}

@property (nonatomic, retain) NSDictionary *dictRegistrant;
@property (nonatomic, retain) UIActivityIndicatorView *progressInd;
@property (nonatomic, retain) NSMutableData *responseData;
@property (nonatomic, retain) NSMutableArray *attendees;



@end
91 changes: 48 additions & 43 deletions Classes/AttendeeListViewController.m
Expand Up @@ -11,21 +11,43 @@
#import <Three20/Three20.h>
#import "JSON.h"



@implementation AttendeeListViewController
@synthesize attendees, responseData, dictRegistrant;
@synthesize attendees, responseData, dictRegistrant, progressInd;

#pragma mark -
#pragma mark Initialization

/*
- (id)initWithStyle:(UITableViewStyle)style {
// Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
if ((self = [super initWithStyle:style])) {
}
return self;
-(id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle {
if (self = [super initWithNibName:nibName bundle:bundle]){
self.title = @"Hi! And you are...?";
UIImage* image = [UIImage imageNamed:@"group.png"];
self.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"People" image:image tag:0] autorelease];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Not you?" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
}
return self;
}
*/

- (UIActivityIndicatorView *)progressInd {
if (progressInd == nil)
{
CGRect frame = CGRectMake(self.view.frame.size.width/2-15, self.view.frame.size.height/2-15, 30, 30);
progressInd = [[UIActivityIndicatorView alloc] initWithFrame:frame];
[progressInd startAnimating];
progressInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
[progressInd sizeToFit];
progressInd.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);

progressInd.tag = 1; // tag this view for later so we can remove it from recycled table cells
}
return progressInd;
}

#pragma mark -
#pragma mark View lifecycle
Expand All @@ -44,9 +66,12 @@ - (void)viewDidLoad {
// fields with URLs that will be visited when the row is selected

//Initialize the array.
responseData = [[NSMutableData data] retain];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://cocoa:camp@cocoacamp.org/registers/json?user_name=cocoa&password=camp"]];
[[NSURLConnection alloc] initWithRequest:request delegate:self ];
if (responseData == nil){
responseData = [[NSMutableData data] retain];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://cocoa:camp@cocoacamp.org/registers/json?user_name=cocoa&password=camp"]];
[[NSURLConnection alloc] initWithRequest:request delegate:self ];
[self.view addSubview: self.progressInd];
}
presenterIcon = [UIImage imageNamed:@"keynote-icon.png"];
[self.tableView reloadData];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
Expand All @@ -55,36 +80,11 @@ - (void)viewDidLoad {



- (void)viewWillAppear:(BOOL)animated {
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//Set the title
self.navigationItem.title = @"CocoaCamp Attendees";
[self.tableView reloadData];
}

/*
- (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 WebService
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
Expand All @@ -101,7 +101,7 @@ - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)err

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
//[connection release];

[self.progressInd removeFromSuperview];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];

Expand Down Expand Up @@ -145,8 +145,6 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {

}



#pragma mark -
#pragma mark Table view data source

Expand Down Expand Up @@ -256,14 +254,17 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
reg.company = [currentReg objectForKey:@"company"];
reg.twitter = [currentReg objectForKey:@"twitter"];
reg.industry = [currentReg objectForKey:@"industry"];
reg.email = [currentReg objectForKey:@"email"];
reg.rid = [NSNumber numberWithInt:[[currentReg objectForKey:@"id"] integerValue]];

NSLog(@"Attendee selected: %@ %@", reg.firstName, reg.lastName);

detailViewController.currRegistrant = reg;
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];

[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}


Expand All @@ -287,9 +288,13 @@ - (void)dealloc {
[responseData release];
[dictRegistrant release];
[attendees release];
[progressInd release];
[super dealloc];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return YES;
}

@end

6 changes: 4 additions & 2 deletions Classes/CocoaCampAppDelegate.m
Expand Up @@ -10,7 +10,8 @@
#import "ContactManager.h"
#import "SessionViewController.h"
#import "FlickrThumbnailView.h"
#import "ContactExchangeViewController.h"
#import "AttendeeListViewController.h"
#import "TwitterFeedTableViewController.h"
#import "TabController.h"

@implementation CocoaCampAppDelegate
Expand All @@ -28,7 +29,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[map from:@"tt://tabs" toViewController:[TabController class]];
[map from:@"tt://schedule" toViewController:[SessionViewController class]];
[map from:@"tt://flickr" toViewController:[FlickrThumbnailView class]];
[map from:@"tt://people" toViewController:[ContactExchangeViewController class]];
[map from:@"tt://people" toViewController:[AttendeeListViewController class]];
[map from:@"tt://twitter" toViewController:[TwitterFeedTableViewController class]];

//if (![navigator restoreViewControllers]) {
[navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://tabs"]];
Expand Down
19 changes: 0 additions & 19 deletions Classes/ContactExchangeViewController.h

This file was deleted.

90 changes: 0 additions & 90 deletions Classes/ContactExchangeViewController.m

This file was deleted.

3 changes: 2 additions & 1 deletion Classes/ContactManager.h
Expand Up @@ -9,14 +9,15 @@
#import <Foundation/Foundation.h>
#import <AddressBook/AddressBook.h>
#import "BumpContact.h"
#import "Registrant.h"

@interface ContactManager : NSObject {
ABAddressBookRef addressBook;
}

+ (ContactManager *)sharedInstance;
- (NSError *)addContactForBumpContact:(BumpContact *)contact;

- (BumpContact *)bumpContactForRegistrant:(Registrant *)registrant;
@end

@interface BumpContact (AddressBook)
Expand Down
17 changes: 17 additions & 0 deletions Classes/ContactManager.m
Expand Up @@ -8,6 +8,7 @@

#import "ContactManager.h"
#import "BumpContact.h"
#import "Registrant.h"

static ContactManager *sharedInstance;

Expand Down Expand Up @@ -38,6 +39,22 @@ - (NSError *)addContactForBumpContact:(BumpContact *)contact {
return (NSError *)error;
}

- (BumpContact *)bumpContactForRegistrant:(Registrant *)registrant
{
if(!registrant)
{
NSLog(@"Received nil registration in bumpContactForRegistrant - for shame!");
return nil;
}

BumpContact *contact = [[BumpContact alloc] init];
contact.firstName = registrant.firstName;
contact.lastName = registrant.lastName;
contact.companyName = registrant.company;

return [contact autorelease];
}

@end

@implementation BumpContact (AddressBook)
Expand Down
20 changes: 20 additions & 0 deletions Classes/NSString+XMLEntities.h
@@ -0,0 +1,20 @@
//
// NSString+XMLEntities.h
// MWFeedParser
//
// Created by Michael Waterfall on 11/05/2010.
// Copyright 2010 d3i. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSString (XMLEntities)

// Instance Methods
- (NSString *)stringByStrippingTags;
- (NSString *)stringByDecodingXMLEntities;
- (NSString *)stringByEncodingXMLEntities;
- (NSString *)stringWithNewLinesAsBRs;
- (NSString *)stringByRemovingNewLinesAndWhitespace;

@end

0 comments on commit d6425c2

Please sign in to comment.