Skip to content

Commit

Permalink
cleaned up code & added loading check to infinite scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
jtdaugh committed Mar 21, 2013
1 parent 4d60021 commit 8b73dae
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 111 deletions.
17 changes: 3 additions & 14 deletions MarketLoco/CategoriesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,24 @@ - (void)viewDidLoad
self.peekRightAmount = 40.0f;
[self.slidingViewController setAnchorRightPeekAmount:self.peekRightAmount];
self.slidingViewController.underLeftWidthLayout = ECVariableRevealWidth;

// Do any additional setup after loading the view.
}






- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[[ParseData sharedParseData] categories] count]+1;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 50;
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

Expand All @@ -66,7 +62,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

}
NSString *title;
if (indexPath.row > 0) {
Expand All @@ -82,7 +77,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *title;
if (indexPath.row == 0) {
Expand All @@ -102,11 +96,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}







- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
Expand Down
3 changes: 1 addition & 2 deletions MarketLoco/FancyCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#import <Parse/Parse.h>
//#import "AppDelegate.h"

@interface FancyCell : UITableViewCell <MFMailComposeViewControllerDelegate,
MFMessageComposeViewControllerDelegate>
@interface FancyCell : UITableViewCell

@property (nonatomic, strong) IBOutlet UILabel *title;
@property (nonatomic, strong) IBOutlet UILabel *description;
Expand Down
4 changes: 1 addition & 3 deletions MarketLoco/FancyCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,21 @@ -(IBAction)contactSellerClicked {
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];

}
}


-(void)displaySMSComposerSheet
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
[item fetchIfNeeded];

controller.body = [NSString stringWithFormat:@"I'm interested in \"%@.\" ", [item objectForKey:@"title"]];
controller.recipients = [NSArray arrayWithObject:[item objectForKey:@"postedBy"]];
controller.messageComposeDelegate = [APP_DELEGATE viewController];
[[APP_DELEGATE viewController] presentModalViewController:controller animated:YES];
}
//do nothing (OS will alert user of error)
}


Expand Down
3 changes: 1 addition & 2 deletions MarketLoco/NetworksViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>

@interface NetworksViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, MFMailComposeViewControllerDelegate,
MFMessageComposeViewControllerDelegate>
@interface NetworksViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) IBOutlet UITableView *networkTable;

Expand Down
15 changes: 4 additions & 11 deletions MarketLoco/NetworksViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
return self;
}


- (void)viewDidLoad
{
[super viewDidLoad];
Expand All @@ -38,32 +39,28 @@ - (void)viewDidLoad
}






- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[[ParseData sharedParseData] networks] count] + 1;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 50;
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"networkCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

}
[cell.textLabel setTextColor:[UIColor colorWithRed:250 green:250 blue:250 alpha:1]];
if (indexPath.row < [[[ParseData sharedParseData] networks] count]) {
Expand All @@ -74,12 +71,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
} else {
[cell.textLabel setText:@"+ Add Your Campus"];
}

return cell;
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row < [[[ParseData sharedParseData] networks] count]) {

Expand Down Expand Up @@ -112,10 +107,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];

}
}

}


Expand Down
6 changes: 4 additions & 2 deletions MarketLoco/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#import "CategoriesViewController.h"

@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, CLLocationManagerDelegate, MFMailComposeViewControllerDelegate,
MFMessageComposeViewControllerDelegate>
MFMessageComposeViewControllerDelegate> {
bool currentlyLoadingMore;
}

@property (nonatomic, strong) CLLocationManager *locationManager;
@property (nonatomic,strong)CLLocation *userLocation;
Expand All @@ -39,7 +41,7 @@ MFMessageComposeViewControllerDelegate>
-(void)addItemsToBottomFromIndex:(int)startIndex;
-(void)getMoreObjectsWithQuery:(PFQuery *)query andStartIndex:(int) startIndex;
-(void)geoQueryForNetwork;
-(void) makeBarPretty;
-(void)makeBarPretty;

- (IBAction)revealNetworks:(id)sender;
- (IBAction)revealCategories:(id)sender;
Expand Down
Loading

0 comments on commit 8b73dae

Please sign in to comment.