[NUI] fix initialize layouter on empty count source insertion (#3172)
authorSangHyeon Jade Lee <sh10233.lee@samsung.com>
Wed, 9 Jun 2021 10:51:34 +0000 (19:51 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 14 Jun 2021 10:12:19 +0000 (19:12 +0900)
src/Tizen.NUI.Components/Controls/RecyclerView/Layouter/GridLayouter.cs
src/Tizen.NUI.Components/Controls/RecyclerView/Layouter/LinearLayouter.cs

index 48cdaee..b05488d 100755 (executable)
@@ -44,6 +44,7 @@ namespace Tizen.NUI.Components
         private Extents groupFooterMargin;
         private GroupInfo Visited;
         private Timer requestLayoutTimer = null;
+        private bool isSourceEmpty;
 
         /// <summary>
         /// Clean up ItemsLayouter.
@@ -114,6 +115,13 @@ namespace Tizen.NUI.Components
                 colView.UnrealizeItem(footer);
             }
 
+            if (pureCount == 0)
+            {
+                isSourceEmpty = true;
+                return;
+            }
+            isSourceEmpty = false;
+
             int firstIndex = header? 1 : 0;
 
             if (colView.IsGrouped)
@@ -486,6 +494,10 @@ namespace Tizen.NUI.Components
         {
             // Insert Single item.
             if (source == null) throw new ArgumentNullException(nameof(source));
+            if (isSourceEmpty)
+            {
+                Initialize(colView);
+            }
 
             // Will be null if not a group.
             float currentSize = 0;
@@ -633,6 +645,10 @@ namespace Tizen.NUI.Components
         {
              // Insert Group
             if (source == null) throw new ArgumentNullException(nameof(source));
+            if (isSourceEmpty)
+            {
+                Initialize(colView);
+            }
 
             float currentSize = 0;
             // Will be null if not a group.
index b915b17..7b4344d 100755 (executable)
@@ -44,6 +44,7 @@ namespace Tizen.NUI.Components
         private Extents groupFooterMargin;
         private GroupInfo Visited;
         private Timer requestLayoutTimer = null;
+        private bool isSourceEmpty;
 
         /// <summary>
         /// Clean up ItemsLayouter.
@@ -109,7 +110,12 @@ namespace Tizen.NUI.Components
             else hasFooter = false;
 
             //No Internal Source exist.
-            if (count == (hasHeader? (hasFooter? 2 : 1) : 0)) return;
+            if (count == (hasHeader? (hasFooter? 2 : 1) : 0))
+            {
+                isSourceEmpty = true;
+                return;
+            }
+            isSourceEmpty = false;
 
             int firstIndex = hasHeader? 1 : 0;
 
@@ -536,6 +542,11 @@ namespace Tizen.NUI.Components
             // Insert Single item.
             if (source == null) throw new ArgumentNullException(nameof(source));
 
+            if (isSourceEmpty)
+            {
+                Initialize(colView);
+            }
+
             // Will be null if not a group.
             float currentSize = StepCandidate;
             IGroupableItemSource gSource = source as IGroupableItemSource;
@@ -686,6 +697,11 @@ namespace Tizen.NUI.Components
              // Insert Group
             if (source == null) throw new ArgumentNullException(nameof(source));
 
+            if (isSourceEmpty)
+            {
+                Initialize(colView);
+            }
+
             float currentSize = StepCandidate;
             // Will be null if not a group.
             IGroupableItemSource gSource = source as IGroupableItemSource;