mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 11:50:56 +00:00
Clean up caching of collection view delegate selectors on the inspector
This commit is contained in:
parent
084d60883b
commit
e8ce7fcbb2
@ -334,7 +334,7 @@ static BOOL _isInterceptedSelector(SEL sel)
|
|||||||
_asyncDelegateImplementsInsetSection = ([_asyncDelegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)] ? 1 : 0);
|
_asyncDelegateImplementsInsetSection = ([_asyncDelegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)] ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[_flowLayoutInspector cacheSelectorsForCollectionView:self];
|
[_layoutInspector didChangeCollectionViewDelegate:asyncDelegate];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setCollectionViewLayout:(UICollectionViewLayout *)collectionViewLayout
|
- (void)setCollectionViewLayout:(UICollectionViewLayout *)collectionViewLayout
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#import <AsyncDisplayKit/ASDimension.h>
|
#import <AsyncDisplayKit/ASDimension.h>
|
||||||
|
|
||||||
@class ASCollectionView;
|
@class ASCollectionView;
|
||||||
|
@protocol ASCollectionViewDelegate;
|
||||||
|
|
||||||
@protocol ASCollectionViewLayoutInspecting <NSObject>
|
@protocol ASCollectionViewLayoutInspecting <NSObject>
|
||||||
|
|
||||||
@ -29,6 +30,13 @@
|
|||||||
*/
|
*/
|
||||||
- (NSUInteger)collectionView:(ASCollectionView *)collectionView supplementaryNodesOfKind:(NSString *)kind inSection:(NSUInteger)section;
|
- (NSUInteger)collectionView:(ASCollectionView *)collectionView supplementaryNodesOfKind:(NSString *)kind inSection:(NSUInteger)section;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow the inspector to respond to delegate changes.
|
||||||
|
*
|
||||||
|
* @discussion A great time to update perform selector caches!
|
||||||
|
*/
|
||||||
|
- (void)didChangeCollectionViewDelegate:(id<ASCollectionViewDelegate>)delegate;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface ASCollectionViewFlowLayoutInspector : NSObject <ASCollectionViewLayoutInspecting>
|
@interface ASCollectionViewFlowLayoutInspector : NSObject <ASCollectionViewLayoutInspecting>
|
||||||
@ -37,6 +45,4 @@
|
|||||||
|
|
||||||
- (instancetype)initWithCollectionView:(ASCollectionView *)collectionView flowLayout:(UICollectionViewFlowLayout *)flowLayout;
|
- (instancetype)initWithCollectionView:(ASCollectionView *)collectionView flowLayout:(UICollectionViewFlowLayout *)flowLayout;
|
||||||
|
|
||||||
- (void)cacheSelectorsForCollectionView:(ASCollectionView *)collectionView;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -30,19 +30,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (self != nil) {
|
if (self != nil) {
|
||||||
[self cacheSelectorsForCollectionView:collectionView];
|
[self didChangeCollectionViewDelegate:collectionView.asyncDelegate];
|
||||||
_layout = flowLayout;
|
_layout = flowLayout;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)cacheSelectorsForCollectionView:(ASCollectionView *)collectionView
|
- (void)didChangeCollectionViewDelegate:(id<ASCollectionViewDelegate>)delegate;
|
||||||
{
|
{
|
||||||
if (collectionView == nil) {
|
if (delegate == nil) {
|
||||||
_delegateImplementsReferenceSizeForHeader = nil;
|
_delegateImplementsReferenceSizeForHeader = nil;
|
||||||
_delegateImplementsReferenceSizeForFooter = nil;
|
_delegateImplementsReferenceSizeForFooter = nil;
|
||||||
} else {
|
} else {
|
||||||
id<ASCollectionViewDelegateFlowLayout> delegate = [self delegateForCollectionView:collectionView];
|
|
||||||
_delegateImplementsReferenceSizeForHeader = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForHeaderInSection:)];
|
_delegateImplementsReferenceSizeForHeader = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForHeaderInSection:)];
|
||||||
_delegateImplementsReferenceSizeForFooter = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForFooterInSection:)];
|
_delegateImplementsReferenceSizeForFooter = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForFooterInSection:)];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user