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
This commit is contained in:
Maxime Ollivier 2020-09-08 09:06:16 -07:00 committed by Facebook GitHub Bot
parent 0693ca6be5
commit 29d4640997

View file

@ -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;
}