Revert "Merge pull request #2649 from facebook/AHCollectionNodeInitializer"

This reverts commit 0f620f458d815b6f7a6b5d954ac29a6d056caf58, reversing
changes made to 0c65d21f8de3023c6d3a25572da18e3b82a35040.
This commit is contained in:
Adlai Holler 2016-11-23 15:56:24 -08:00
parent 0f620f458d
commit 14765a55d2
3 changed files with 15 additions and 28 deletions

View File

@ -33,19 +33,19 @@ NS_ASSUME_NONNULL_BEGIN
*
* @discussion Initializes and returns a newly allocated collection node object with the specified layout.
*
* @param layout The layout object to use for organizing items. The collection node stores a strong reference to the specified object. Must not be nil.
* @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil.
*/
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout;
/**
* Initializes an ASCollectionNode
*
* @discussion Initializes and returns a newly allocated collection node object with the specified layout.
* @discussion Initializes and returns a newly allocated collection node object with the specified frame and layout.
*
* @param layout The layout object to use for organizing items. The collection node stores a strong reference to the specified object. Must not be nil.
* @param layoutInspector The layout inspector to use, or nil to use the ASDK default layout inspector.
* @param frame The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview in which you plan to add it. This frame is passed to the superclass during initialization.
* @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil.
*/
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout layoutInspector:(nullable id<ASCollectionViewLayoutInspecting>)layoutInspector;
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout;
/**
* Returns the corresponding ASCollectionView
@ -416,16 +416,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface ASCollectionNode (Deprecated)
/**
* Initializes an ASCollectionNode
*
* @discussion Initializes and returns a newly allocated collection node object with the specified frame and layout.
*
* @param frame The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview in which you plan to add it. This frame is passed to the superclass during initialization.
* @param layout The layout object to use for organizing items. The collection view stores a strong reference to the specified object. Must not be nil.
*/
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout ASDISPLAYNODE_DEPRECATED_MSG("Use -initWithCollectionViewLayout: instead.");
/**
* Reload everything from scratch, destroying the working range and all cached nodes.
*

View File

@ -111,22 +111,20 @@
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout
{
return [self initWithCollectionViewLayout:layout layoutInspector:nil];
return [self initWithFrame:CGRectZero collectionViewLayout:layout];
}
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout layoutInspector:(id<ASCollectionViewLayoutInspecting>)layoutInspector
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout
{
return [self initWithCollectionViewLayout:layout layoutInspector:layoutInspector layoutFacilitator:nil];
return [self initWithFrame:frame collectionViewLayout:layout layoutFacilitator:nil];
}
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout layoutInspector:(id<ASCollectionViewLayoutInspecting>)layoutInspector layoutFacilitator:(id<ASCollectionViewLayoutFacilitatorProtocol>)layoutFacilitator
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout layoutFacilitator:(id<ASCollectionViewLayoutFacilitatorProtocol>)layoutFacilitator
{
__weak __typeof__(self) weakSelf = self;
ASDisplayNodeViewBlock collectionViewBlock = ^UIView *{
__typeof__(self) strongSelf = weakSelf;
ASCollectionView *collectionView = [[ASCollectionView alloc] _initWithFrame:CGRectZero collectionViewLayout:layout layoutFacilitator:layoutFacilitator eventLog:ASDisplayNodeGetEventLog(strongSelf)];
collectionView.layoutInspector = layoutInspector;
return collectionView;
return [[ASCollectionView alloc] _initWithFrame:frame collectionViewLayout:layout layoutFacilitator:layoutFacilitator eventLog:ASDisplayNodeGetEventLog(strongSelf)];
};
if (self = [super initWithViewBlock:collectionViewBlock]) {

View File

@ -148,12 +148,11 @@
self.asyncDelegate = [[ASCollectionViewTestDelegate alloc] initWithNumberOfSections:10 numberOfItemsInSection:10];
id realLayout = [UICollectionViewFlowLayout new];
id mockLayout = [OCMockObject partialMockForObject:realLayout];
self.collectionNode = [[ASCollectionNode alloc] initWithCollectionViewLayout:mockLayout];
self.collectionNode.frame = self.view.bounds;
self.collectionNode.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.collectionNode = [[ASCollectionNode alloc] initWithFrame:self.view.bounds collectionViewLayout:mockLayout];
self.collectionView = self.collectionNode.view;
self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.collectionNode.dataSource = self.asyncDelegate;
self.collectionNode.delegate = self.asyncDelegate;
self.collectionView = self.collectionNode.view;
[self.collectionNode registerSupplementaryNodeOfKind:UICollectionElementKindSectionHeader];
[self.view addSubview:self.collectionView];
@ -367,7 +366,7 @@
*/
- (void)testThatCollectionNodeConformsToExpectedProtocols
{
ASCollectionNode *node = [[ASCollectionNode alloc] initWithCollectionViewLayout:[[UICollectionViewFlowLayout alloc] init]];
ASCollectionNode *node = [[ASCollectionNode alloc] initWithFrame:CGRectZero collectionViewLayout:[[UICollectionViewFlowLayout alloc] init]];
XCTAssert([node conformsToProtocol:@protocol(ASRangeControllerUpdateRangeProtocol)]);
}
@ -553,7 +552,7 @@
{
UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UICollectionViewLayout *layout = [[UICollectionViewFlowLayout alloc] init];
ASCollectionNode *cn = [[ASCollectionNode alloc] initWithCollectionViewLayout:layout];
ASCollectionNode *cn = [[ASCollectionNode alloc] initWithFrame:window.bounds collectionViewLayout:layout];
ASCollectionView *cv = cn.view;