From 29d464099782813113246da47cb9c7bf4676a311 Mon Sep 17 00:00:00 2001 From: Maxime Ollivier Date: Tue, 8 Sep 2020 09:06:16 -0700 Subject: [PATCH] create emptyViewForListAdapter only when needed Summary: We don't need to create the `emptyViewForListAdapter` if it's hidden Reviewed By: patters Differential Revision: D23429238 fbshipit-source-id: 8d85964c177f53a0e0cc0867339c1cbf0db2ee4e --- Source/IGListKit/IGListAdapter.m | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Source/IGListKit/IGListAdapter.m b/Source/IGListKit/IGListAdapter.m index e097f59b..fe2f9d34 100644 --- a/Source/IGListKit/IGListAdapter.m +++ b/Source/IGListKit/IGListAdapter.m @@ -791,14 +791,18 @@ if (self.isInUpdateBlock) { return; // will be called again when update block completes } - UIView *backgroundView = [self.dataSource emptyViewForListAdapter:self]; - // don't do anything if the client is using the same view - if (backgroundView != _collectionView.backgroundView) { - // collection view will just stack the background views underneath each other if we do not remove the previous - // one first. also fine if it is nil - [_collectionView.backgroundView removeFromSuperview]; - _collectionView.backgroundView = backgroundView; + + if (!shouldHide || !_experimentalUpdater) { + UIView *backgroundView = [self.dataSource emptyViewForListAdapter:self]; + // don't do anything if the client is using the same view + if (backgroundView != _collectionView.backgroundView) { + // collection view will just stack the background views underneath each other if we do not remove the previous + // one first. also fine if it is nil + [_collectionView.backgroundView removeFromSuperview]; + _collectionView.backgroundView = backgroundView; + } } + _collectionView.backgroundView.hidden = shouldHide; }