Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
ItemsViewController measurementCells null check (#15638)
Browse files Browse the repository at this point in the history
  • Loading branch information
reid-kirkpatrick committed Jan 9, 2023
1 parent c1a8878 commit 33dd32a
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void CheckForEmptySource()
if (_isEmpty)
{
UnbindCells();
_measurementCells.Clear();
_measurementCells?.Clear();
ItemsViewLayout?.ClearCellSizeCache();
}

Expand Down Expand Up @@ -231,7 +231,7 @@ protected virtual IItemsViewSource CreateItemsViewSource()

public virtual void UpdateItemsSource()
{
_measurementCells.Clear();
_measurementCells?.Clear();
ItemsViewLayout?.ClearCellSizeCache();
ItemsSource?.Dispose();
ItemsSource = CreateItemsViewSource();
Expand Down Expand Up @@ -275,7 +275,7 @@ protected virtual void UpdateTemplatedCell(TemplatedCell cell, NSIndexPath index
var bindingContext = ItemsSource[indexPath];

// If we've already created a cell for this index path (for measurement), re-use the content
if (_measurementCells.TryGetValue(bindingContext, out TemplatedCell measurementCell))
if (_measurementCells != null && _measurementCells.TryGetValue(bindingContext, out TemplatedCell measurementCell))
{
_measurementCells.Remove(bindingContext);
measurementCell.ContentSizeChanged -= CellContentSizeChanged;
Expand Down Expand Up @@ -620,7 +620,8 @@ public UICollectionViewCell CreateMeasurementCell(NSIndexPath indexPath)
UpdateTemplatedCell(templatedCell, indexPath);

// Keep this cell around, we can transfer the contents to the actual cell when the UICollectionView creates it
_measurementCells[ItemsSource[indexPath]] = templatedCell;
if (_measurementCells != null)
_measurementCells[ItemsSource[indexPath]] = templatedCell;

return templatedCell;
}
Expand Down

2 comments on commit 33dd32a

@oridotaoyebode
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reid-kirkpatrick did this change ever make it to a nuget release. Last release was last year

@reid-kirkpatrick
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reid-kirkpatrick did this change ever make it to a nuget release. Last release was last year

@oridotaoyebode #15638 (comment)

Please sign in to comment.