Skip to content

Commit

Permalink
Show refresh header on explicit reload
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Stadnik committed Apr 17, 2012
1 parent 1176754 commit 6848f18
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions BADemo/BARefreshHeaderViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ - (void)contentDidChange:(NSTimer *)timer {
}
}

- (void)reload {
_loading = YES;
[NSTimer scheduledTimerWithTimeInterval:3
target:self
selector:@selector(contentDidChange:)
userInfo:nil
repeats:NO];
}

- (void)extReload {
[_refreshHeaderView dataSourceDidStartLoading:self.tableView];
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
[self reload];
}

- (void)viewDidLoad {
[super viewDidLoad];
CGRect headerFrame = CGRectMake(0,
Expand All @@ -72,18 +87,16 @@ - (void)viewDidLoad {
_refreshHeaderView.arrowImageLayer.contents = (id)[UIImage imageNamed:@"ba-refresh-black.png"].CGImage;
_refreshHeaderView.activityView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
[_refreshHeaderView refreshLastUpdatedDate];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self
action:@selector(extReload)] autorelease];
}

#pragma mark -
#pragma mark Refresh Header Callbacks

- (void)refreshHeaderDidTriggerRefresh:(BARefreshHeaderView *)view {
_loading = YES;
[NSTimer scheduledTimerWithTimeInterval:3
target:self
selector:@selector(contentDidChange:)
userInfo:nil
repeats:NO];
[self reload];
}

- (BOOL)refreshHeaderDataSourceLoading:(BARefreshHeaderView *)view {
Expand Down

0 comments on commit 6848f18

Please sign in to comment.