mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 03:09: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);
|
||||
}
|
||||
|
||||
[_flowLayoutInspector cacheSelectorsForCollectionView:self];
|
||||
[_layoutInspector didChangeCollectionViewDelegate:asyncDelegate];
|
||||
}
|
||||
|
||||
- (void)setCollectionViewLayout:(UICollectionViewLayout *)collectionViewLayout
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#import <AsyncDisplayKit/ASDimension.h>
|
||||
|
||||
@class ASCollectionView;
|
||||
@protocol ASCollectionViewDelegate;
|
||||
|
||||
@protocol ASCollectionViewLayoutInspecting <NSObject>
|
||||
|
||||
@ -29,6 +30,13 @@
|
||||
*/
|
||||
- (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
|
||||
|
||||
@interface ASCollectionViewFlowLayoutInspector : NSObject <ASCollectionViewLayoutInspecting>
|
||||
@ -37,6 +45,4 @@
|
||||
|
||||
- (instancetype)initWithCollectionView:(ASCollectionView *)collectionView flowLayout:(UICollectionViewFlowLayout *)flowLayout;
|
||||
|
||||
- (void)cacheSelectorsForCollectionView:(ASCollectionView *)collectionView;
|
||||
|
||||
@end
|
||||
|
||||
@ -30,19 +30,18 @@
|
||||
}
|
||||
|
||||
if (self != nil) {
|
||||
[self cacheSelectorsForCollectionView:collectionView];
|
||||
[self didChangeCollectionViewDelegate:collectionView.asyncDelegate];
|
||||
_layout = flowLayout;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)cacheSelectorsForCollectionView:(ASCollectionView *)collectionView
|
||||
- (void)didChangeCollectionViewDelegate:(id<ASCollectionViewDelegate>)delegate;
|
||||
{
|
||||
if (collectionView == nil) {
|
||||
if (delegate == nil) {
|
||||
_delegateImplementsReferenceSizeForHeader = nil;
|
||||
_delegateImplementsReferenceSizeForFooter = nil;
|
||||
} else {
|
||||
id<ASCollectionViewDelegateFlowLayout> delegate = [self delegateForCollectionView:collectionView];
|
||||
_delegateImplementsReferenceSizeForHeader = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForHeaderInSection:)];
|
||||
_delegateImplementsReferenceSizeForFooter = [delegate respondsToSelector:@selector(collectionView:layout:referenceSizeForFooterInSection:)];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user