Skip to content

Commit

Permalink
[NUI] Fix Layouter to handle empty group case.
Browse files Browse the repository at this point in the history
  • Loading branch information
everLEEst committed Nov 25, 2022
1 parent 1b55db4 commit 0364f0c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,19 @@ public override void Initialize(RecyclerView view)

bool failed = false;
//Final Check of FirstIndex
while (colView.InternalItemSource.IsHeader(firstIndex) ||
if (colView.InternalItemSource.Count - 1 < firstIndex)
{
StepCandidate = 0F;
failed = true;
}

while (!failed &&
(colView.InternalItemSource.IsHeader(firstIndex) ||
colView.InternalItemSource.IsGroupHeader(firstIndex) ||
colView.InternalItemSource.IsGroupFooter(firstIndex))
colView.InternalItemSource.IsGroupFooter(firstIndex)))
{
if (colView.InternalItemSource.IsFooter(firstIndex))
if (colView.InternalItemSource.IsFooter(firstIndex)
|| ((colView.InternalItemSource.Count - 1) <= firstIndex))
{
StepCandidate = 0F;
failed = true;
Expand Down Expand Up @@ -509,7 +517,7 @@ public override void NotifyItemInserted(IItemSource source, int startIndex)
// Insert Single item.
if (source == null) throw new ArgumentNullException(nameof(source));
if (colView == null) return;
if (isSourceEmpty)
if (isSourceEmpty || StepCandidate == 0)
{
Initialize(colView);
}
Expand Down Expand Up @@ -661,7 +669,7 @@ public override void NotifyItemRangeInserted(IItemSource source, int startIndex,
// Insert Group
if (source == null) throw new ArgumentNullException(nameof(source));
if (colView == null) return;
if (isSourceEmpty)
if (isSourceEmpty || StepCandidate == 0)
{
Initialize(colView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,19 @@ public override void Initialize(RecyclerView view)
bool failed = false;

//Final Check of FirstIndex
while (colView.InternalItemSource.IsHeader(firstIndex) ||

if (colView.InternalItemSource.Count - 1 < firstIndex)
{
StepCandidate = 0F;
failed = true;
}

while (!failed &&
(colView.InternalItemSource.IsHeader(firstIndex) ||
colView.InternalItemSource.IsGroupHeader(firstIndex) ||
colView.InternalItemSource.IsGroupFooter(firstIndex))
colView.InternalItemSource.IsGroupFooter(firstIndex)))
{

if (colView.InternalItemSource.IsFooter(firstIndex)
|| ((colView.InternalItemSource.Count - 1) <= firstIndex))
{
Expand Down Expand Up @@ -557,7 +566,7 @@ public override void NotifyItemInserted(IItemSource source, int startIndex)
if (source == null) throw new ArgumentNullException(nameof(source));
if (colView == null) return;

if (isSourceEmpty)
if (isSourceEmpty || StepCandidate == 0)
{
Initialize(colView);
}
Expand Down Expand Up @@ -725,7 +734,7 @@ public override void NotifyItemRangeInserted(IItemSource source, int startIndex,
if (source == null) throw new ArgumentNullException(nameof(source));
if (colView == null) return;

if (isSourceEmpty)
if (isSourceEmpty || StepCandidate == 0)
{
Initialize(colView);
}
Expand Down

0 comments on commit 0364f0c

Please sign in to comment.