Skip to content

Commit

Permalink
refresh labs list when app returns from background
Browse files Browse the repository at this point in the history
  • Loading branch information
cdzombak committed Feb 11, 2012
1 parent 5c46d3e commit 71fc548
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
11 changes: 7 additions & 4 deletions CAENLabStatus/DZCAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
@interface DZCAppDelegate ()

@property (nonatomic, strong) DZCDataController *dataController;
@property (nonatomic, strong) DZCLabsViewController *labsViewController;
@property (nonatomic, assign) BOOL appWasInBackground;

@end

@implementation DZCAppDelegate

@synthesize window = _window, rootViewController = _viewController, dataController = _dataController, appWasInBackground = _appWasInBackground;
@synthesize window = _window, rootViewController = _viewController, dataController = _dataController, labsViewController = _labsViewController, appWasInBackground = _appWasInBackground;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
DZCLabsViewController *labsViewController = [[DZCLabsViewController alloc] initWithStyle:UITableViewStylePlain];
labsViewController.dataController = self.dataController;
self.labsViewController = [[DZCLabsViewController alloc] initWithStyle:UITableViewStylePlain];
self.labsViewController.dataController = self.dataController;

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:labsViewController];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.labsViewController];

self.rootViewController = navController;
} else {
Expand All @@ -45,6 +46,8 @@ - (void)applicationDidBecomeActive:(UIApplication *)application
if (self.appWasInBackground) {
[self.dataController clearCache];
[self.dataController reloadLabStatusesWithBlock:nil];

[self.labsViewController refreshData];
}
}

Expand Down
2 changes: 2 additions & 0 deletions CAENLabStatus/DZCLabsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

@property(nonatomic, strong) DZCDataController *dataController;

- (void)refreshData;

@end
5 changes: 3 additions & 2 deletions CAENLabStatus/DZCLabsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ @interface DZCLabsViewController ()
@property (nonatomic, strong) NSArray *labs;

- (void)loadData;
- (void)refreshData;

@end

Expand Down Expand Up @@ -184,7 +183,7 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte
return DZCLabsTableViewSectionTitles[section];
}

#pragma mark - Private methods
#pragma mark - Data Management

- (void)refreshData
{
Expand All @@ -193,6 +192,8 @@ - (void)refreshData
[self loadData];
}

#pragma mark - Private methods

- (void)loadData
{
[self.dataController labsAndStatusesWithBlock:^(NSDictionary *labs, NSError *error) {
Expand Down

0 comments on commit 71fc548

Please sign in to comment.