Skip to content

Commit

Permalink
Fix compilation isuses, add beginLoading method, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
grp committed Dec 23, 2011
1 parent a451580 commit 5405a50
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions PullToRefreshView.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef enum {
kPullToRefreshViewStateNormal,
kPullToRefreshViewStateReady,
kPullToRefreshViewStateLoading,
kPullToRefreshViewStateProgrammaticRefresh,
kPullToRefreshViewStateOffline
} PullToRefreshViewState;

Expand All @@ -57,8 +58,8 @@ typedef enum {
- (void)refreshLastUpdatedDate;

- (id)initWithScrollView:(UIScrollView *)scrollView;
- (void)didFinishLoading;
- (void)didStartLoading:(BOOL)scrollToReveal;
- (void)finishedLoading;
- (void)beginLoading;
- (void)containingViewDidUnload;

@end
Expand Down
11 changes: 8 additions & 3 deletions PullToRefreshView.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ - (void)showActivity:(BOOL)show animated:(BOOL)animated {

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:(animated ? kPullToRefreshViewAnimationDuration : 0.0)];
arrowImage.opacity = (shouldShow ? 0.0 : 1.0);
arrowImage.opacity = (show ? 0.0 : 1.0);
[UIView commitAnimations];
}

Expand Down Expand Up @@ -130,8 +130,12 @@ - (void)refreshLastUpdatedDate {
[formatter release];
}

- (void)beginLoading {
[self setState:kPullToRefreshViewStateProgrammaticRefresh];
}

- (void)finishedLoading {
if (state == kPullToRefreshViewStateLoading) {
if (state == kPullToRefreshViewStateLoading || state == kPullToRefreshViewStateProgrammaticRefresh) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3f];
[self setState:kPullToRefreshViewStateNormal];
Expand All @@ -158,6 +162,7 @@ - (void)setState:(PullToRefreshViewState)state_ {
scrollView.contentInset = UIEdgeInsetsZero;
break;
case kPullToRefreshViewStateLoading:
case kPullToRefreshViewStateProgrammaticRefresh:
statusLabel.text = @"Loading…";
[self showActivity:YES animated:YES];
[self setImageFlipped:NO];
Expand Down Expand Up @@ -189,7 +194,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
// go to the ready state.
[self setState:kPullToRefreshViewStateReady];
}
} else if (state == kPullToRefreshViewStateLoading) {
} else if (state == kPullToRefreshViewStateLoading || state == kPullToRefreshViewStateProgrammaticRefresh) {
// if the user scrolls the view down while we're loading, make sure the loading screen is visible if they scroll to the top:

if (scrollView.contentOffset.y >= 0) {
Expand Down
3 changes: 3 additions & 0 deletions testbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# this will fail with _main undefined, but should work otherwise
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk PullToRefreshView.m -arch armv7 -framework Foundation -framework UIKit -miphoneos-version-min=4.0 -framework QuartzCore

0 comments on commit 5405a50

Please sign in to comment.