From c9dcc43b03dd3044d88291889ee676ccd1a958e1 Mon Sep 17 00:00:00 2001 From: Justin Bergen Date: Wed, 10 Oct 2012 16:09:36 -0600 Subject: [PATCH 1/2] Add support for optional streaming state --- .../Classes/View/EGORefreshTableHeaderView.h | 6 +- .../Classes/View/EGORefreshTableHeaderView.m | 60 +++++++++++++++---- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h index 0ec72f0..4d278ee 100755 --- a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h +++ b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h @@ -30,7 +30,8 @@ typedef enum{ EGOOPullRefreshPulling = 0, EGOOPullRefreshNormal, - EGOOPullRefreshLoading, + EGOOPullRefreshLoading, + EGOOPullRefreshStreaming, } EGOPullRefreshState; @protocol EGORefreshTableHeaderDelegate; @@ -55,6 +56,8 @@ typedef enum{ - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView; - (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView; - (void)egoRefreshScrollViewDataSourceDidFinishedLoading:(UIScrollView *)scrollView; +- (void)egoRefreshScrollViewDataSourceDidBeginStreaming:(UIScrollView *)scrollView; +- (void)egoRefreshScrollViewDataSourceDidEndStreaming:(UIScrollView *)scrollView; @end @protocol EGORefreshTableHeaderDelegate @@ -62,4 +65,5 @@ typedef enum{ - (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view; @optional - (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view; +- (BOOL)egoRefreshTableHeaderDataSourceIsStreaming:(EGORefreshTableHeaderView *)view; @end diff --git a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m index 56b345b..94e2bfa 100755 --- a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m +++ b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m @@ -90,7 +90,6 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI _activityView = view; [view release]; - [self setState:EGOOPullRefreshNormal]; } @@ -107,7 +106,11 @@ - (id)initWithFrame:(CGRect)frame { #pragma mark Setters - (void)refreshLastUpdatedDate { - + if (_state == EGOOPullRefreshStreaming) { + _lastUpdatedLabel.text = nil; + return; + } + if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceLastUpdated:)]) { NSDate *date = [_delegate egoRefreshTableHeaderDataSourceLastUpdated:self]; @@ -171,11 +174,22 @@ - (void)setState:(EGOPullRefreshState)aState{ [CATransaction commit]; break; + case EGOOPullRefreshStreaming: + + _statusLabel.text = NSLocalizedString(@"Streaming...", @"Streaming status"); + [_activityView startAnimating]; + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + _arrowImage.hidden = YES; + [CATransaction commit]; + + break; default: break; } _state = aState; + [self refreshLastUpdatedDate]; } @@ -214,11 +228,15 @@ - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView { - (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView { BOOL _loading = NO; + BOOL _streaming = NO; if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsLoading:)]) { _loading = [_delegate egoRefreshTableHeaderDataSourceIsLoading:self]; } + if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDataSourceIsStreaming:)]) { + _streaming = [_delegate egoRefreshTableHeaderDataSourceIsStreaming:self]; + } - if (scrollView.contentOffset.y <= - 65.0f && !_loading) { + if (scrollView.contentOffset.y <= - 65.0f && !_loading && !_streaming) { if ([_delegate respondsToSelector:@selector(egoRefreshTableHeaderDidTriggerRefresh:)]) { [_delegate egoRefreshTableHeaderDidTriggerRefresh:self]; @@ -235,14 +253,36 @@ - (void)egoRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView { } - (void)egoRefreshScrollViewDataSourceDidFinishedLoading:(UIScrollView *)scrollView { - - [UIView beginAnimations:nil context:NULL]; - [UIView setAnimationDuration:.3]; - [scrollView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)]; - [UIView commitAnimations]; - - [self setState:EGOOPullRefreshNormal]; + if (_state == EGOOPullRefreshLoading) { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:.3]; + [scrollView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)]; + [UIView commitAnimations]; + } + + [self setState:EGOOPullRefreshNormal]; +} +- (void)egoRefreshScrollViewDataSourceDidBeginStreaming:(UIScrollView *)scrollView { + if (_state == EGOOPullRefreshLoading) { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:.3]; + [scrollView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)]; + [UIView commitAnimations]; + } + + [self setState:EGOOPullRefreshStreaming]; +} + +- (void)egoRefreshScrollViewDataSourceDidEndStreaming:(UIScrollView *)scrollView { + if (_state == EGOOPullRefreshLoading) { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:.3]; + [scrollView setContentInset:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)]; + [UIView commitAnimations]; + } + + [self setState:EGOOPullRefreshNormal]; } From c1f6bc6f6f20b772686620246b720cc518e5aaf2 Mon Sep 17 00:00:00 2001 From: Justin Bergen Date: Wed, 10 Oct 2012 16:38:04 -0600 Subject: [PATCH 2/2] Remove pesky .DS_Store --- Demo/TableViewPull/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Demo/TableViewPull/.DS_Store diff --git a/Demo/TableViewPull/.DS_Store b/Demo/TableViewPull/.DS_Store deleted file mode 100644 index b17ff1ba75c5669e5a9b2eeda5851cd304c1f552..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5T0$Trl^pM(BtB{NTh{$@DM@;k75cvSkc538YoR^5_+i7;0yT*K84TY z%<<74zlcu(YyhxO2?ZH7Lhjm7!z2qtR2-v#B|N|cvS?K^ z&~J3n+S_nVYlige`m;qeOCyZFMvGaJ<&N_%8qLT^F^{vGV4ALi zB%Va!@>bb-m=~EJE>+|z%%>Pp_ApInXpc?yD2emwo!wcl`_5Tc_FT8@%C+k{UD@xs zW!Xlt->jqKlk>}A_*gzYSDHmZ3nw|$uxVd578}d}Gr$Zm1I$1z1Lg>^_G_c;WCoal z|I7gG4-%EoGgxUDseR;cmvE06U