From 943cae7eb9b79d0c89b274f0ed13201a9e1bd3d8 Mon Sep 17 00:00:00 2001 From: Scott Goodson Date: Sat, 28 Nov 2015 17:45:43 -0800 Subject: [PATCH] Placeholder implementation of -setInterfaceState:. --- AsyncDisplayKit/ASDisplayNode.h | 2 +- AsyncDisplayKit/ASDisplayNode.mm | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKit/ASDisplayNode.h b/AsyncDisplayKit/ASDisplayNode.h index 62663267ec..51adccbc1c 100644 --- a/AsyncDisplayKit/ASDisplayNode.h +++ b/AsyncDisplayKit/ASDisplayNode.h @@ -46,7 +46,7 @@ typedef NS_OPTIONS(NSUInteger, ASInterfaceState) ASInterfaceStateMeasureLayout = 1 << 1, /** The element is likely enough to come onscreen that disk and/or network data required for display should be fetched. */ ASInterfaceStateFetchData = 1 << 2, - /** The elemant is very likely to become visible, and concurrent rendering should be executed for any -setNeedsDisplay. */ + /** The element is very likely to become visible, and concurrent rendering should be executed for any -setNeedsDisplay. */ ASInterfaceStateDisplay = 1 << 3, /** The element is physically onscreen by at least 1 pixel. In practice, all other bit fields should also be set when this flag is set. */ diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index 394c050128..4095552b77 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -1692,6 +1692,39 @@ void recursivelyEnsureDisplayForLayer(CALayer *layer) - (void)setInterfaceState:(ASInterfaceState)interfaceState { if (interfaceState != _interfaceState) { + if ((interfaceState & ASInterfaceStateMeasureLayout) != (_interfaceState & ASInterfaceStateMeasureLayout)) { + // Trigger asynchronous measurement if it is not already cached or being calculated. + } + + // Entered or exited data loading state. + if ((interfaceState & ASInterfaceStateFetchData) != (_interfaceState & ASInterfaceStateFetchData)) { + if (interfaceState & ASInterfaceStateFetchData) { + [self fetchData]; + } else { + [self clearFetchedData]; + } + } + + // Entered or exited contents rendering state. + if ((interfaceState & ASInterfaceStateDisplay) != (_interfaceState & ASInterfaceStateDisplay)) { + if (interfaceState & ASInterfaceStateDisplay) { + // Once the working window is eliminated (ASRangeHandlerRender), trigger display directly here. + [self setDisplaySuspended:NO]; + } else { + [self setDisplaySuspended:YES]; + [self clearContents]; + } + } + + // Entered or exited data loading state. + if ((interfaceState & ASInterfaceStateVisible) != (_interfaceState & ASInterfaceStateVisible)) { + if (interfaceState & ASInterfaceStateVisible) { + // Consider providing a -didBecomeVisible. + } else { + // Consider providing a -didBecomeInvisible. + } + } + _interfaceState = interfaceState; } }