mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
added a callback for initWithViewBlock/initWithLayerBlock
This commit is contained in:
@@ -256,33 +256,47 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
|
||||
- (id)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock
|
||||
{
|
||||
if (!(self = [super init]))
|
||||
return nil;
|
||||
|
||||
ASDisplayNodeAssertNotNil(viewBlock, @"should initialize with a valid block that returns a UIView");
|
||||
|
||||
[self _initializeInstance];
|
||||
_viewBlock = viewBlock;
|
||||
_flags.synchronous = YES;
|
||||
|
||||
return self;
|
||||
return [self initWithViewBlock:viewBlock viewDidLoadBlock:nil];
|
||||
}
|
||||
|
||||
- (id)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock
|
||||
- (id)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock viewDidLoadBlock:(ASDisplayNodeViewLoadedBlock)viewLoadedBlock
|
||||
{
|
||||
if (!(self = [super init]))
|
||||
return nil;
|
||||
|
||||
ASDisplayNodeAssertNotNil(layerBlock, @"should initialize with a valid block that returns a CALayer");
|
||||
|
||||
|
||||
ASDisplayNodeAssertNotNil(viewBlock, @"should initialize with a valid block that returns a UIView");
|
||||
|
||||
[self _initializeInstance];
|
||||
_layerBlock = layerBlock;
|
||||
_viewBlock = viewBlock;
|
||||
_viewLoadedBlock = viewLoadedBlock;
|
||||
_flags.synchronous = YES;
|
||||
_flags.layerBacked = YES;
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (id)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock
|
||||
{
|
||||
return [self initWithLayerBlock:layerBlock layerDidLoadBlock:nil];
|
||||
}
|
||||
|
||||
- (id)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock layerDidLoadBlock:(ASDisplayNodeLayerLoadedBlock)layerLoadedBlock
|
||||
{
|
||||
if (!(self = [super init]))
|
||||
return nil;
|
||||
|
||||
ASDisplayNodeAssertNotNil(layerBlock, @"should initialize with a valid block that returns a CALayer");
|
||||
|
||||
[self _initializeInstance];
|
||||
_layerBlock = layerBlock;
|
||||
_layerLoadedBlock = layerLoadedBlock;
|
||||
_flags.synchronous = YES;
|
||||
_flags.layerBacked = YES;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
@@ -424,7 +438,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
}
|
||||
{
|
||||
TIME_SCOPED(_debugTimeForDidLoad);
|
||||
[self didLoad];
|
||||
[self __didLoad];
|
||||
}
|
||||
|
||||
if (self.placeholderEnabled) {
|
||||
@@ -1482,6 +1496,17 @@ static NSInteger incrementIfFound(NSInteger i) {
|
||||
_flags.isMeasured = NO;
|
||||
}
|
||||
|
||||
- (void)__didLoad
|
||||
{
|
||||
if (_viewLoadedBlock) {
|
||||
_viewLoadedBlock(_view);
|
||||
}
|
||||
if (_layerLoadedBlock) {
|
||||
_layerLoadedBlock(_layer);
|
||||
}
|
||||
[self didLoad];
|
||||
}
|
||||
|
||||
- (void)didLoad
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
Reference in New Issue
Block a user