[NUI] Fix Layouter to handle empty group case.
authoreverLEEst(SangHyeon Lee) <sh10233.lee@samsung.com>
Fri, 25 Nov 2022 06:18:12 +0000 (22:18 -0800)
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>
Wed, 29 Mar 2023 05:40:29 +0000 (14:40 +0900)
src/Tizen.NUI.Components/Controls/RecyclerView/Layouter/GridLayouter.cs
src/Tizen.NUI.Components/Controls/RecyclerView/Layouter/LinearLayouter.cs

index c4a406a..8dca378 100755 (executable)
@@ -210,11 +210,19 @@ namespace Tizen.NUI.Components
 
             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;
@@ -509,7 +517,7 @@ namespace Tizen.NUI.Components
             // Insert Single item.
             if (source == null) throw new ArgumentNullException(nameof(source));
             if (colView == null) return;
-            if (isSourceEmpty)
+            if (isSourceEmpty || StepCandidate == 0)
             {
                 Initialize(colView);
             }
@@ -661,7 +669,7 @@ namespace Tizen.NUI.Components
              // Insert Group
             if (source == null) throw new ArgumentNullException(nameof(source));
             if (colView == null) return;
-            if (isSourceEmpty)
+            if (isSourceEmpty || StepCandidate == 0)
             {
                 Initialize(colView);
             }
index 52bb6ec..612602b 100755 (executable)
@@ -204,10 +204,19 @@ namespace Tizen.NUI.Components
             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))
                 {
@@ -557,7 +566,7 @@ namespace Tizen.NUI.Components
             if (source == null) throw new ArgumentNullException(nameof(source));
             if (colView == null) return;
 
-            if (isSourceEmpty)
+            if (isSourceEmpty || StepCandidate == 0)
             {
                 Initialize(colView);
             }
@@ -725,7 +734,7 @@ namespace Tizen.NUI.Components
             if (source == null) throw new ArgumentNullException(nameof(source));
             if (colView == null) return;
 
-            if (isSourceEmpty)
+            if (isSourceEmpty || StepCandidate == 0)
             {
                 Initialize(colView);
             }