Skip to content

Commit

Permalink
[pagingscrollview] Don't notify delegate of page change when reloadDa…
Browse files Browse the repository at this point in the history
…ta is called.
jverkoey committed Sep 20, 2012
1 parent 1b50f35 commit 49e665f
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -82,6 +82,8 @@ - (void)loadThumbnails {
[self loadThumbnails];
[self.photoAlbumView reloadData];
[self.photoScrubberView reloadData];

[self refreshChromeState];
};
}

Original file line number Diff line number Diff line change
@@ -108,6 +108,8 @@ - (void)loadThumbnails {
[self loadThumbnails];
[self.photoAlbumView reloadData];
[self.photoScrubberView reloadData];

[self refreshChromeState];
};
}

14 changes: 7 additions & 7 deletions src/pagingscrollview/src/NIPagingScrollView.m
Original file line number Diff line number Diff line change
@@ -343,7 +343,7 @@ - (void)displayPageAtIndex:(NSInteger)pageIndex {


///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)updateVisiblePagesAnimated:(BOOL)animated {
- (void)updateVisiblePagesShouldNotifyDelegate:(BOOL)shouldNotifyDelegate {
NSRange visiblePageRange = [self visiblePageRange];

// Recycle no-longer-visible pages. We copy _visiblePages because we may modify it while we're
@@ -380,7 +380,7 @@ - (void)updateVisiblePagesAnimated:(BOOL)animated {
_centerPageIndex = -1;
}

if (!animated && oldCenterPageIndex != _centerPageIndex
if (shouldNotifyDelegate && oldCenterPageIndex != _centerPageIndex
&& [self.delegate respondsToSelector:@selector(pagingScrollViewDidChangePages:)]) {
[self.delegate pagingScrollViewDidChangePages:self];
}
@@ -434,7 +434,7 @@ - (void)setFrame:(CGRect)frame {

///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[self updateVisiblePagesAnimated:NO];
[self updateVisiblePagesShouldNotifyDelegate:YES];
_isKillingAnimation = NO;
}

@@ -467,7 +467,7 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
_isKillingAnimation = NO;

if (!decelerate) {
[self updateVisiblePagesAnimated:NO];
[self updateVisiblePagesShouldNotifyDelegate:YES];
[self resetSurroundingPages];
}

@@ -479,7 +479,7 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL

///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
[self updateVisiblePagesAnimated:NO];
[self updateVisiblePagesShouldNotifyDelegate:YES];
[self resetSurroundingPages];

if ([self.delegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)]) {
@@ -601,7 +601,7 @@ - (void)reloadData {
}

// Begin requesting the page information from the data source.
[self updateVisiblePagesAnimated:NO];
[self updateVisiblePagesShouldNotifyDelegate:NO];
}


@@ -678,7 +678,7 @@ - (void)didAnimateToPage:(NSNumber *)pageIndex {
self.pagingScrollView.contentOffset = offset;
_isModifyingContentOffset = NO;

[self updateVisiblePagesAnimated:YES];
[self updateVisiblePagesShouldNotifyDelegate:NO];
}


1 change: 1 addition & 0 deletions src/photos/src/NIToolbarPhotoViewController.h
Original file line number Diff line number Diff line change
@@ -113,6 +113,7 @@
@property (nonatomic, readonly, retain) UIToolbar* toolbar;
@property (nonatomic, readonly, retain) NIPhotoAlbumScrollView* photoAlbumView;
@property (nonatomic, readonly, retain) NIPhotoScrubberView* photoScrubberView;
- (void)refreshChromeState;


#pragma mark Toolbar Buttons

0 comments on commit 49e665f

Please sign in to comment.