Skip to content

Commit

Permalink
create emptyViewForListAdapter only when needed
Browse files Browse the repository at this point in the history
Summary: We don't need to create the `emptyViewForListAdapter` if it's hidden

Reviewed By: patters

Differential Revision: D23429238

fbshipit-source-id: 8d85964c177f53a0e0cc0867339c1cbf0db2ee4e
  • Loading branch information
maxolls authored and facebook-github-bot committed Sep 8, 2020
1 parent 0693ca6 commit 29d4640
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Source/IGListKit/IGListAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -791,14 +791,18 @@ - (void)_updateBackgroundViewShouldHide:(BOOL)shouldHide {
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;
}

Expand Down

0 comments on commit 29d4640

Please sign in to comment.