Skip to content

Commit

Permalink
Merge branch 'master' into astableview-in-xib
Browse files Browse the repository at this point in the history
  • Loading branch information
eanagel committed May 5, 2015
2 parents c81f5d0 + f248dbd commit a38cf3e
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
9 changes: 9 additions & 0 deletions AsyncDisplayKit/ASCollectionView.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@
*/
@property (nonatomic, assign) CGFloat leadingScreensForBatching;

/**
* Reload everything from scratch, destroying the working range and all cached nodes.
*
* @param completion block to run on completion of asynchronous loading or nil. If supplied, the block is run on
* the main thread.
* @warning This method is substantially more expensive than UICollectionView's version.
*/
- (void)reloadDataWithCompletion:(void (^)())completion;

/**
* Reload everything from scratch, destroying the working range and all cached nodes.
*
Expand Down
9 changes: 7 additions & 2 deletions AsyncDisplayKit/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,18 @@ - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionVi
#pragma mark -
#pragma mark Overrides.

- (void)reloadData
- (void)reloadDataWithCompletion:(void (^)())completion
{
ASDisplayNodeAssert(self.asyncDelegate, @"ASCollectionView's asyncDelegate property must be set.");
ASDisplayNodePerformBlockOnMainThread(^{
[super reloadData];
});
[_dataController reloadDataWithAnimationOption:kASCollectionViewAnimationNone];
[_dataController reloadDataWithAnimationOption:kASCollectionViewAnimationNone completion:completion];
}

- (void)reloadData
{
[self reloadDataWithCompletion:nil];
}

- (void)setDataSource:(id<UICollectionViewDataSource>)dataSource
Expand Down
2 changes: 1 addition & 1 deletion AsyncDisplayKit/ASControlNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ - (void)addTarget:(id)target action:(SEL)action forControlEvents:(ASControlNodeE
if (!eventDispatchTable)
{
// Create the dispatch table for this event.
eventDispatchTable = [NSMapTable strongToStrongObjectsMapTable];
eventDispatchTable = [NSMapTable weakToStrongObjectsMapTable];
[_controlEventDispatchTable setObject:eventDispatchTable forKey:eventKey];
}

Expand Down
9 changes: 9 additions & 0 deletions AsyncDisplayKit/ASTableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@
*/
@property (nonatomic, assign) CGFloat leadingScreensForBatching;

/**
* Reload everything from scratch, destroying the working range and all cached nodes.
*
* @param completion block to run on completion of asynchronous loading or nil. If supplied, the block is run on
* the main thread.
* @warning This method is substantially more expensive than UITableView's version.
*/
-(void)reloadDataWithCompletion:(void (^)())completion;

/**
* Reload everything from scratch, destroying the working range and all cached nodes.
*
Expand Down
9 changes: 7 additions & 2 deletions AsyncDisplayKit/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,18 @@ - (void)setAsyncDelegate:(id<ASTableViewDelegate>)asyncDelegate
}
}

- (void)reloadData
- (void)reloadDataWithCompletion:(void (^)())completion
{
ASDisplayNodeAssert(self.asyncDelegate, @"ASTableView's asyncDelegate property must be set.");
ASDisplayNodePerformBlockOnMainThread(^{
[super reloadData];
});
[_dataController reloadDataWithAnimationOption:UITableViewRowAnimationNone];
[_dataController reloadDataWithAnimationOption:UITableViewRowAnimationNone completion:completion];
}

- (void)reloadData
{
[self reloadDataWithCompletion:nil];
}

- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType
Expand Down
2 changes: 1 addition & 1 deletion AsyncDisplayKit/Details/ASDataController.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ typedef NSUInteger ASDataControllerAnimationOptions;

- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath withAnimationOption:(ASDataControllerAnimationOptions)animationOption;;

- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption;;
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption completion:(void (^)())completion;

/** @name Data Querying */

Expand Down
6 changes: 5 additions & 1 deletion AsyncDisplayKit/Details/ASDataController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ - (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)n
});
}

- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption completion:(void (^)())completion
{
[self performDataFetchingWithBlock:^{
// Fetching data in calling thread
Expand Down Expand Up @@ -478,6 +478,10 @@ - (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animatio
}];

[self _batchInsertNodes:updatedNodes atIndexPaths:updatedIndexPaths withAnimationOptions:animationOption];

if (completion) {
dispatch_async(dispatch_get_main_queue(), completion);
}
});
}];
}
Expand Down

0 comments on commit a38cf3e

Please sign in to comment.