mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 03:09:56 +00:00
Merge pull request #461 from facebook/memoryMethods
Updating API names for network range and memory culling before ASDK 1.2 tag.
This commit is contained in:
commit
b9597ff96b
@ -190,8 +190,9 @@
|
||||
*
|
||||
* @discussion Subclasses may override this method to be notified when they should begin to fetch data. Fetching
|
||||
* should be done asynchronously. The node is also responsible for managing the memory of any data.
|
||||
* The data may be remote and accessed via the network, but could also be a local database query.
|
||||
*/
|
||||
- (void)fetchRemoteData ASDISPLAYNODE_REQUIRES_SUPER;
|
||||
- (void)fetchData ASDISPLAYNODE_REQUIRES_SUPER;
|
||||
|
||||
/**
|
||||
* @abstract Indicates that the receiver is about to display its subnodes. This method is not called if there are no
|
||||
@ -323,18 +324,18 @@
|
||||
* Provides an opportunity to clear backing store and other memory-intensive intermediates, such as text layout managers
|
||||
* on the current node.
|
||||
*
|
||||
* @discussion Called by -recursivelyClearRendering. Base class implements self.contents = nil, clearing any backing
|
||||
* @discussion Called by -recursivelyClearContents. Base class implements self.contents = nil, clearing any backing
|
||||
* store, for asynchronous regeneration when needed.
|
||||
*/
|
||||
- (void)clearRendering ASDISPLAYNODE_REQUIRES_SUPER;
|
||||
- (void)clearContents ASDISPLAYNODE_REQUIRES_SUPER;
|
||||
|
||||
/**
|
||||
* Provides an opportunity to clear any remote data on the current node.
|
||||
* Provides an opportunity to clear any fetched data (e.g. remote / network or database-queried) on the current node.
|
||||
*
|
||||
* @discussion This will not clear data recursively for all subnodes. Either call -recursivelyClearRemoteData or
|
||||
* selectively clear remote data.
|
||||
* @discussion This will not clear data recursively for all subnodes. Either call -recursivelyClearFetchedData or
|
||||
* selectively clear fetched data.
|
||||
*/
|
||||
- (void)clearRemoteData ASDISPLAYNODE_REQUIRES_SUPER;
|
||||
- (void)clearFetchedData ASDISPLAYNODE_REQUIRES_SUPER;
|
||||
|
||||
|
||||
/** @name Placeholders */
|
||||
|
||||
@ -312,7 +312,7 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)();
|
||||
- (void)recursivelySetDisplaySuspended:(BOOL)flag;
|
||||
|
||||
/**
|
||||
* @abstract Calls -clearRendering on the receiver and its subnode hierarchy.
|
||||
* @abstract Calls -clearContents on the receiver and its subnode hierarchy.
|
||||
*
|
||||
* @discussion Clears backing stores and other memory-intensive intermediates.
|
||||
* If the node is removed from a visible hierarchy and then re-added, it will automatically trigger a new asynchronous display,
|
||||
@ -322,27 +322,27 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)();
|
||||
* @see displaySuspended and setNeedsDisplay
|
||||
*/
|
||||
|
||||
- (void)recursivelyClearRendering;
|
||||
- (void)recursivelyClearContents;
|
||||
|
||||
/**
|
||||
* @abstract Calls -clearRemoteData on the receiver and its subnode hierarchy.
|
||||
* @abstract Calls -clearFetchedData on the receiver and its subnode hierarchy.
|
||||
*
|
||||
* @discussion Clears any memory-intensive fetched content.
|
||||
* This method is used to notify the node that it should purge any content that is both expensive to fetch and to
|
||||
* retain in memory.
|
||||
*
|
||||
* @see clearRemoteData and fetchRemoteData
|
||||
* @see clearFetchedData and fetchData
|
||||
*/
|
||||
- (void)recursivelyClearRemoteData;
|
||||
- (void)recursivelyClearFetchedData;
|
||||
|
||||
/**
|
||||
* @abstract Calls -fetchRemoteData on the receiver and its subnode hierarchy.
|
||||
* @abstract Calls -fetchData on the receiver and its subnode hierarchy.
|
||||
*
|
||||
* @discussion Fetches content from remote sources for the current node and all subnodes.
|
||||
*
|
||||
* @see fetchRemoteData and clearRemoteData
|
||||
* @see fetchData and clearFetchedData
|
||||
*/
|
||||
- (void)recursivelyFetchRemoteData;
|
||||
- (void)recursivelyFetchData;
|
||||
|
||||
/**
|
||||
* @abstract Toggle displaying a placeholder over the node that covers content until the node and all subnodes are
|
||||
|
||||
@ -90,8 +90,8 @@ void ASDisplayNodePerformBlockOnMainThread(void (^block)())
|
||||
// Subclasses should never override these
|
||||
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(calculatedSize)), @"Subclass %@ must not override calculatedSize method", NSStringFromClass(self));
|
||||
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(measure:)), @"Subclass %@ must not override measure method", NSStringFromClass(self));
|
||||
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(recursivelyClearRendering)), @"Subclass %@ must not override recursivelyClearRendering method", NSStringFromClass(self));
|
||||
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(recursivelyClearRemoteData)), @"Subclass %@ must not override recursivelyClearRemoteData method", NSStringFromClass(self));
|
||||
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(recursivelyClearContents)), @"Subclass %@ must not override recursivelyClearContents method", NSStringFromClass(self));
|
||||
ASDisplayNodeAssert(!ASDisplayNodeSubclassOverridesSelector(self, @selector(recursivelyClearFetchedData)), @"Subclass %@ must not override recursivelyClearFetchedData method", NSStringFromClass(self));
|
||||
}
|
||||
|
||||
+ (BOOL)layerBackedNodesEnabled
|
||||
@ -1331,44 +1331,44 @@ static NSInteger incrementIfFound(NSInteger i) {
|
||||
[self __exitedHierarchy];
|
||||
}
|
||||
|
||||
- (void)clearRendering
|
||||
- (void)clearContents
|
||||
{
|
||||
self.layer.contents = nil;
|
||||
_placeholderLayer.contents = nil;
|
||||
}
|
||||
|
||||
- (void)recursivelyClearRendering
|
||||
- (void)recursivelyClearContents
|
||||
{
|
||||
for (ASDisplayNode *subnode in self.subnodes) {
|
||||
[subnode recursivelyClearRendering];
|
||||
[subnode recursivelyClearContents];
|
||||
}
|
||||
[self clearRendering];
|
||||
[self clearContents];
|
||||
}
|
||||
|
||||
- (void)fetchRemoteData
|
||||
- (void)fetchData
|
||||
{
|
||||
// subclass override
|
||||
}
|
||||
|
||||
- (void)recursivelyFetchRemoteData
|
||||
- (void)recursivelyFetchData
|
||||
{
|
||||
for (ASDisplayNode *subnode in self.subnodes) {
|
||||
[subnode recursivelyFetchRemoteData];
|
||||
[subnode recursivelyFetchData];
|
||||
}
|
||||
[self fetchRemoteData];
|
||||
[self fetchData];
|
||||
}
|
||||
|
||||
- (void)clearRemoteData
|
||||
- (void)clearFetchedData
|
||||
{
|
||||
// subclass override
|
||||
}
|
||||
|
||||
- (void)recursivelyClearRemoteData
|
||||
- (void)recursivelyClearFetchedData
|
||||
{
|
||||
for (ASDisplayNode *subnode in self.subnodes) {
|
||||
[subnode recursivelyClearRemoteData];
|
||||
[subnode recursivelyClearFetchedData];
|
||||
}
|
||||
[self clearRemoteData];
|
||||
[self clearFetchedData];
|
||||
}
|
||||
|
||||
- (void)layout
|
||||
@ -1822,12 +1822,12 @@ static const char *ASDisplayNodeAssociatedNodeKey = "ASAssociatedNode";
|
||||
|
||||
- (void)reclaimMemory
|
||||
{
|
||||
[self clearRendering];
|
||||
[self clearContents];
|
||||
}
|
||||
|
||||
- (void)recursivelyReclaimMemory
|
||||
{
|
||||
[self recursivelyClearRendering];
|
||||
[self recursivelyClearContents];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -162,9 +162,9 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
||||
}
|
||||
|
||||
#pragma mark - ASDisplayNode Overrides
|
||||
- (void)clearRendering
|
||||
- (void)clearContents
|
||||
{
|
||||
[super clearRendering]; // This actually clears the contents, so we need to do this first for our displayedImageIdentifier to be meaningful.
|
||||
[super clearContents]; // This actually clears the contents, so we need to do this first for our displayedImageIdentifier to be meaningful.
|
||||
[self _setDisplayedImageIdentifier:nil withImage:nil];
|
||||
|
||||
if (_downloadIdentifier) {
|
||||
@ -177,12 +177,12 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
||||
{
|
||||
[super displayWillStart];
|
||||
|
||||
[self fetchRemoteData];
|
||||
[self fetchData];
|
||||
}
|
||||
|
||||
- (void)fetchRemoteData
|
||||
- (void)fetchData
|
||||
{
|
||||
[super fetchRemoteData];
|
||||
[super fetchData];
|
||||
|
||||
[self _loadImageIdentifiers];
|
||||
}
|
||||
|
||||
@ -127,12 +127,12 @@
|
||||
{
|
||||
[super displayWillStart];
|
||||
|
||||
[self fetchRemoteData];
|
||||
[self fetchData];
|
||||
}
|
||||
|
||||
- (void)clearRemoteData
|
||||
- (void)clearFetchedData
|
||||
{
|
||||
[super clearRemoteData];
|
||||
[super clearFetchedData];
|
||||
|
||||
{
|
||||
ASDN::MutexLocker l(_lock);
|
||||
@ -143,9 +143,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)fetchRemoteData
|
||||
- (void)fetchData
|
||||
{
|
||||
[super fetchRemoteData];
|
||||
[super fetchData];
|
||||
|
||||
{
|
||||
ASDN::MutexLocker l(_lock);
|
||||
|
||||
@ -226,12 +226,12 @@ ASDISPLAYNODE_INLINE CGFloat ceilPixelValue(CGFloat f)
|
||||
[self _invalidateRenderer];
|
||||
}
|
||||
|
||||
- (void)clearRendering
|
||||
- (void)clearContents
|
||||
{
|
||||
// We discard the backing store and renderer to prevent the very large
|
||||
// memory overhead of maintaining these for all text nodes. They can be
|
||||
// regenerated when layout is necessary.
|
||||
[super clearRendering]; // ASDisplayNode will set layer.contents = nil
|
||||
[super clearContents]; // ASDisplayNode will set layer.contents = nil
|
||||
[self _invalidateRenderer];
|
||||
}
|
||||
|
||||
|
||||
@ -16,13 +16,13 @@
|
||||
- (void)node:(ASDisplayNode *)node enteredRangeOfType:(ASLayoutRangeType)rangeType
|
||||
{
|
||||
ASDisplayNodeAssert(rangeType == ASLayoutRangeTypePreload, @"Preload delegate should not handle other ranges");
|
||||
[node recursivelyFetchRemoteData];
|
||||
[node recursivelyFetchData];
|
||||
}
|
||||
|
||||
- (void)node:(ASDisplayNode *)node exitedRangeOfType:(ASLayoutRangeType)rangeType
|
||||
{
|
||||
ASDisplayNodeAssert(rangeType == ASLayoutRangeTypePreload, @"Preload delegate should not handle other ranges");
|
||||
[node recursivelyClearRemoteData];
|
||||
[node recursivelyClearFetchedData];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
[node recursivelySetDisplaySuspended:YES];
|
||||
[node.view removeFromSuperview];
|
||||
|
||||
[node recursivelyClearRendering];
|
||||
[node recursivelyClearContents];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
XCTAssert([context isCancelled], @"Context should be cancelled");
|
||||
}
|
||||
|
||||
/* This test is currently unreliable. See https://github.com/facebook/AsyncDisplayKit/issues/459
|
||||
- (void)testAsyncContextInvalidation
|
||||
{
|
||||
NSURL *url = [self randomURL];
|
||||
@ -56,6 +57,7 @@
|
||||
[context cancel];
|
||||
[self waitForExpectationsWithTimeout:30.0 handler:nil];
|
||||
}
|
||||
*/
|
||||
|
||||
- (void)testContextSessionCanceled
|
||||
{
|
||||
|
||||
@ -10,4 +10,4 @@ SPEC CHECKSUMS:
|
||||
FBSnapshotTestCase: 3dc3899168747a0319c5278f5b3445c13a6532dd
|
||||
OCMock: a6a7dc0e3997fb9f35d99f72528698ebf60d64f2
|
||||
|
||||
COCOAPODS: 0.36.3
|
||||
COCOAPODS: 0.37.1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user