Skip to content

Commit

Permalink
Contestants info and facebook like page + metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangbus committed Oct 27, 2011
1 parent 75a5553 commit 3a54e2f
Show file tree
Hide file tree
Showing 12 changed files with 894 additions and 17 deletions.
24 changes: 18 additions & 6 deletions LemonadeAlley/LemonadeAlley.xcodeproj/project.pbxproj
Expand Up @@ -10,7 +10,6 @@
A3111B61145432C7001019E7 /* PageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A3111B60145432C7001019E7 /* PageViewController.m */; };
A342AA7A144C4A4E0051DAC3 /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = A342AA79144C4A4E0051DAC3 /* MBProgressHUD.m */; };
A342AA7D144C4AE10051DAC3 /* WordpressPostAgent.m in Sources */ = {isa = PBXBuildFile; fileRef = A342AA7C144C4AE10051DAC3 /* WordpressPostAgent.m */; };
A35145D61453AA9900A10826 /* WordpressPageAgent.m in Sources */ = {isa = PBXBuildFile; fileRef = A35145D51453AA9900A10826 /* WordpressPageAgent.m */; };
A35145D91453B0DB00A10826 /* AboutViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A35145D81453B0DB00A10826 /* AboutViewController.m */; };
A39B315D14566A8D00DE2A88 /* Facebook.m in Sources */ = {isa = PBXBuildFile; fileRef = A39B314614566A8D00DE2A88 /* Facebook.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
A39B315E14566A8D00DE2A88 /* FBDialog.bundle in Resources */ = {isa = PBXBuildFile; fileRef = A39B314814566A8D00DE2A88 /* FBDialog.bundle */; };
Expand All @@ -26,6 +25,9 @@
A3B448341454FEBA0045FCC3 /* nav_bg_44.png in Resources */ = {isa = PBXBuildFile; fileRef = A3B448331454FEBA0045FCC3 /* nav_bg_44.png */; };
A3B4483814550AAC0045FCC3 /* table_bg.png in Resources */ = {isa = PBXBuildFile; fileRef = A3B4483714550AAC0045FCC3 /* table_bg.png */; };
A3B4483A145510970045FCC3 /* lemon_200x200.png in Resources */ = {isa = PBXBuildFile; fileRef = A3B44839145510970045FCC3 /* lemon_200x200.png */; };
A3B4484D145983560045FCC3 /* ContestantsInfoAgent.m in Sources */ = {isa = PBXBuildFile; fileRef = A3B4484A145983560045FCC3 /* ContestantsInfoAgent.m */; };
A3B4484E145983560045FCC3 /* WordpressPageAgent.m in Sources */ = {isa = PBXBuildFile; fileRef = A3B4484C145983560045FCC3 /* WordpressPageAgent.m */; };
A3B44851145983620045FCC3 /* VotingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A3B44850145983620045FCC3 /* VotingViewController.m */; };
A3D1306D144BD0E50019A696 /* NewsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A3D1306B144BD0E50019A696 /* NewsViewController.m */; };
A3D1309C144BD3C90019A696 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3D1309B144BD3C80019A696 /* CFNetwork.framework */; };
A3D1309E144BD3D90019A696 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3D1309D144BD3D90019A696 /* MobileCoreServices.framework */; };
Expand Down Expand Up @@ -267,8 +269,6 @@
A342AA79144C4A4E0051DAC3 /* MBProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MBProgressHUD.m; path = vendor/MBProgressHUD.m; sourceTree = "<group>"; };
A342AA7B144C4AE10051DAC3 /* WordpressPostAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WordpressPostAgent.h; path = models/WordpressPostAgent.h; sourceTree = "<group>"; };
A342AA7C144C4AE10051DAC3 /* WordpressPostAgent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WordpressPostAgent.m; path = models/WordpressPostAgent.m; sourceTree = "<group>"; };
A35145D41453AA9900A10826 /* WordpressPageAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WordpressPageAgent.h; sourceTree = "<group>"; };
A35145D51453AA9900A10826 /* WordpressPageAgent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WordpressPageAgent.m; sourceTree = "<group>"; };
A35145D71453B0DB00A10826 /* AboutViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AboutViewController.h; sourceTree = "<group>"; };
A35145D81453B0DB00A10826 /* AboutViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AboutViewController.m; sourceTree = "<group>"; };
A39B314514566A8D00DE2A88 /* Facebook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Facebook.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -297,6 +297,12 @@
A3B448331454FEBA0045FCC3 /* nav_bg_44.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = nav_bg_44.png; sourceTree = "<group>"; };
A3B4483714550AAC0045FCC3 /* table_bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = table_bg.png; sourceTree = "<group>"; };
A3B44839145510970045FCC3 /* lemon_200x200.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = lemon_200x200.png; sourceTree = "<group>"; };
A3B44849145983560045FCC3 /* ContestantsInfoAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ContestantsInfoAgent.h; path = models/ContestantsInfoAgent.h; sourceTree = "<group>"; };
A3B4484A145983560045FCC3 /* ContestantsInfoAgent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ContestantsInfoAgent.m; path = models/ContestantsInfoAgent.m; sourceTree = "<group>"; };
A3B4484B145983560045FCC3 /* WordpressPageAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WordpressPageAgent.h; path = models/WordpressPageAgent.h; sourceTree = "<group>"; };
A3B4484C145983560045FCC3 /* WordpressPageAgent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WordpressPageAgent.m; path = models/WordpressPageAgent.m; sourceTree = "<group>"; };
A3B4484F145983620045FCC3 /* VotingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VotingViewController.h; sourceTree = "<group>"; };
A3B44850145983620045FCC3 /* VotingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VotingViewController.m; sourceTree = "<group>"; };
A3D1306A144BD0E50019A696 /* NewsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewsViewController.h; sourceTree = "<group>"; };
A3D1306B144BD0E50019A696 /* NewsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewsViewController.m; sourceTree = "<group>"; };
A3D1309B144BD3C80019A696 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -667,6 +673,8 @@
A3111B60145432C7001019E7 /* PageViewController.m */,
A3DB1230144B934C00DFC686 /* PostViewController.h */,
A3DB1231144B934C00DFC686 /* PostViewController.m */,
A3B4484F145983620045FCC3 /* VotingViewController.h */,
A3B44850145983620045FCC3 /* VotingViewController.m */,
A3DB122A144B934C00DFC686 /* LemonadeAlley.xcdatamodeld */,
A3DB1219144B934B00DFC686 /* Supporting Files */,
);
Expand Down Expand Up @@ -915,10 +923,12 @@
A3E485F2144BD907001FDD13 /* Models */ = {
isa = PBXGroup;
children = (
A3B44849145983560045FCC3 /* ContestantsInfoAgent.h */,
A3B4484A145983560045FCC3 /* ContestantsInfoAgent.m */,
A3B4484B145983560045FCC3 /* WordpressPageAgent.h */,
A3B4484C145983560045FCC3 /* WordpressPageAgent.m */,
A342AA7B144C4AE10051DAC3 /* WordpressPostAgent.h */,
A342AA7C144C4AE10051DAC3 /* WordpressPostAgent.m */,
A35145D41453AA9900A10826 /* WordpressPageAgent.h */,
A35145D51453AA9900A10826 /* WordpressPageAgent.m */,
);
name = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -1242,7 +1252,6 @@
A3D1306D144BD0E50019A696 /* NewsViewController.m in Sources */,
A342AA7A144C4A4E0051DAC3 /* MBProgressHUD.m in Sources */,
A342AA7D144C4AE10051DAC3 /* WordpressPostAgent.m in Sources */,
A35145D61453AA9900A10826 /* WordpressPageAgent.m in Sources */,
A35145D91453B0DB00A10826 /* AboutViewController.m in Sources */,
A3111B61145432C7001019E7 /* PageViewController.m in Sources */,
A39B315D14566A8D00DE2A88 /* Facebook.m in Sources */,
Expand All @@ -1255,6 +1264,9 @@
A39B316514566A8D00DE2A88 /* SBJsonBase.m in Sources */,
A39B316614566A8D00DE2A88 /* SBJsonParser.m in Sources */,
A39B316714566A8D00DE2A88 /* SBJsonWriter.m in Sources */,
A3B4484D145983560045FCC3 /* ContestantsInfoAgent.m in Sources */,
A3B4484E145983560045FCC3 /* WordpressPageAgent.m in Sources */,
A3B44851145983620045FCC3 /* VotingViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
6 changes: 6 additions & 0 deletions LemonadeAlley/LemonadeAlley/AboutViewController.m
Expand Up @@ -32,6 +32,12 @@ - (void)viewDidLoad {

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;

HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
HUD.labelText = @"Loading";
// HUD.userInteractionEnabled = NO;
[self.navigationController.view addSubview:HUD];
[HUD show:YES];
}

- (void)viewDidUnload
Expand Down
2 changes: 1 addition & 1 deletion LemonadeAlley/LemonadeAlley/NewsViewController.m
Expand Up @@ -30,7 +30,7 @@ - (void)viewDidLoad {
wordpressPostAgent = [[WordpressPostAgent alloc] init];
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
HUD.labelText = @"Loading";
HUD.userInteractionEnabled = NO;
// HUD.userInteractionEnabled = NO;
[self.navigationController.view addSubview:HUD];
[HUD show:YES];

Expand Down
18 changes: 18 additions & 0 deletions LemonadeAlley/LemonadeAlley/VotingViewController.h
@@ -0,0 +1,18 @@
//
// VotingViewController.h
// LemonadeAlley
//
// Created by Jian Shi Wang on 10/27/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MBProgressHUD.h"
#import "ContestantsInfoAgent.h"

@interface VotingViewController : UITableViewController

@property (strong, nonatomic) ContestantsInfoAgent *contestantsInfoAgent;
@property (strong, nonatomic) MBProgressHUD *HUD;

@end
210 changes: 210 additions & 0 deletions LemonadeAlley/LemonadeAlley/VotingViewController.m
@@ -0,0 +1,210 @@
//
// VotingViewController.m
// LemonadeAlley
//
// Created by Jian Shi Wang on 10/27/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "VotingViewController.h"


@implementation VotingViewController
@synthesize HUD;
@synthesize contestantsInfoAgent;

- (id)initWithStyle:(UITableViewStyle)style {
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"lemon_200x200.png"]];
contestantsInfoAgent = [[ContestantsInfoAgent alloc] init];
self.parentViewController.title = @"About";
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
HUD.labelText = @"Loading";
// HUD.userInteractionEnabled = NO;
[self.navigationController.view addSubview:HUD];
[HUD show:YES];
}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveDataNotification:)
name:@"ContestantInfoUpdateNotification"
object:nil];
[super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[contestantsInfoAgent contestantsInfos] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSUInteger row = [indexPath row];
NSDictionary *contestantsInfo = [[contestantsInfoAgent contestantsInfos] objectAtIndex:row];

NSLog(@"Page: %@", contestantsInfo);
// Configure the cell...
cell.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.8];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14.0];
// cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.text = [contestantsInfo objectForKey:@"team name"];
// cell.detailTextLabel.font = [UIFont fontWithName:@"Noteworthy-Light" size:14.0];
cell.detailTextLabel.text = [contestantsInfo objectForKey:@"grade division"];
return cell;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if (section == 0) {
return @"Contestants";
}
else {
return @"";
}
}

/*
// 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 - Table view delegate

- (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];
*/
}

- (void) receiveDataNotification:(NSNotification *) notification {
if ([[notification name] isEqualToString:@"ContestantInfoUpdateNotification"]) {
NSLog (@"Successfully received the ContestantInfoUpdateNotification!");
[[self tableView] reloadData];
[HUD hide:YES];
}
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSLog(@"Segue identifier: %@", segue.identifier);

if ([[segue identifier] isEqualToString:@"showPage"]) {
NSLog(@"ShowDetails from prepareforsegue");
NSInteger row = [[self.tableView indexPathForSelectedRow] row];
NSDictionary *contestantInfo = [contestantsInfoAgent.contestantsInfos objectAtIndex:row];

// [segue destinationViewController] is read-only, so in order to
// write to that view controller you'll have to locally instantiate
// it here:
// PageViewController *detailViewController = [segue destinationViewController];
// detailViewController.page = page;

// You now have a solid reference to the upcoming / destination view
// controller. Example use: Allocate and initialize some property of
// the destination view controller before you reach it and inject a
// reference to the current view controller into the upcoming one:
// upcomingViewController.someProperty = [[SomePropertyClass alloc] initWithString:@"Whatever!"];
// upcomingViewController. = [segue sourceViewController];

// Or, equivalent, but more straightforward:
//upcomingViewController.initialViewController = self;
}
}
@end

0 comments on commit 3a54e2f

Please sign in to comment.