[NUI] Fix some SVACE issues.
authorzhouhao02 <haozhou.zhou@samsung.com>
Fri, 17 Nov 2023 08:26:02 +0000 (16:26 +0800)
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>
Wed, 22 Nov 2023 08:42:16 +0000 (17:42 +0900)
src/Tizen.NUI.Components/Controls/RecyclerView/ItemSource/MarshalingObservableCollection.cs
src/Tizen.NUI.Components/Controls/RecyclerView/ItemSource/ObservableGroupedSource.cs
src/Tizen.NUI.Components/Controls/RecyclerView/ItemSource/ObservableItemSource.cs

index 92dc48f..44074d8 100755 (executable)
@@ -110,7 +110,7 @@ namespace Tizen.NUI.Components
 
         void Move(NotifyCollectionChangedEventArgs args)
         {
-            var count = args.OldItems.Count;
+            int count = args.OldItems?.Count ?? 0;
 
             for (int n = 0; n < count; n++)
             {
@@ -124,7 +124,8 @@ namespace Tizen.NUI.Components
 
         void Remove(NotifyCollectionChangedEventArgs args)
         {
-            var startIndex = args.OldStartingIndex + args.OldItems.Count - 1;
+            int count=args.OldItems?.Count ?? 0;
+            int startIndex = args.OldStartingIndex + count - 1;
             for (int n = startIndex; n >= args.OldStartingIndex; n--)
             {
                 RemoveAt(n);
index a0247d5..9357843 100755 (executable)
@@ -337,7 +337,7 @@ namespace Tizen.NUI.Components
             }
 
             // If we have a start index, we can be more clever about removing the group(s) (and get the nifty animations)
-            var groupCount = args.OldItems.Count;
+            int groupCount = args.OldItems?.Count ?? 0;
 
             var absolutePosition = GetAbsolutePosition(groups[groupIndex], 0);
 
@@ -360,9 +360,15 @@ namespace Tizen.NUI.Components
 
         void Replace(NotifyCollectionChangedEventArgs args)
         {
-            var groupCount = args.NewItems.Count;
-
-            if (groupCount != args.OldItems.Count)
+            var newItems = args.NewItems;
+            var oldItems = args.OldItems;
+            if(newItems == null || oldItems == null)
+            {
+                return;
+            }       
+            int groupCount = newItems.Count;
+            int oldCount = oldItems.Count;
+            if (groupCount != oldCount)
             {
                 // The original and replacement sets are of unequal size; this means that most everything currently in 
                 // view will have to be updated. So just reload the whole thing.
@@ -370,8 +376,8 @@ namespace Tizen.NUI.Components
                 return;
             }
 
-            var newStartIndex = args.NewStartingIndex > -1 ? args.NewStartingIndex : groupSource.IndexOf(args.NewItems[0]);
-            var oldStartIndex = args.OldStartingIndex > -1 ? args.OldStartingIndex : groupSource.IndexOf(args.OldItems[0]);
+            var newStartIndex = args.NewStartingIndex > -1 ? args.NewStartingIndex : groupSource.IndexOf(newItems[0]);
+            var oldStartIndex = args.OldStartingIndex > -1 ? args.OldStartingIndex : groupSource.IndexOf(oldItems[0]);
 
             var newItemCount = CountItemsInGroups(newStartIndex, groupCount);
             var oldItemCount = CountItemsInGroups(oldStartIndex, groupCount);
@@ -402,7 +408,7 @@ namespace Tizen.NUI.Components
 
         void Move(NotifyCollectionChangedEventArgs args)
         {
-            var itemCount = CountItemsInGroups(args.OldStartingIndex, args.OldItems.Count);
+            var itemCount = CountItemsInGroups(args.OldStartingIndex, args.OldItems?.Count ?? 0);
             var start = Math.Min(args.OldStartingIndex, args.NewStartingIndex);
             var end = Math.Max(args.OldStartingIndex, args.NewStartingIndex) + itemCount;
 
index 616485d..a70b4ca 100755 (executable)
@@ -187,7 +187,7 @@ namespace Tizen.NUI.Components
             startIndex = AdjustPositionForHeader(startIndex);
 
             // If we have a start index, we can be more clever about removing the item(s) (and get the nifty animations)
-            var count = args.OldItems.Count;
+            int count = args.OldItems?.Count ?? 0;
 
             if (count == 1)
             {
@@ -200,11 +200,18 @@ namespace Tizen.NUI.Components
 
         void Replace(NotifyCollectionChangedEventArgs args)
         {
+            var newItems = args.NewItems;
+            var oldItems = args.OldItems;
+            if (newItems == null || oldItems == null)
+            {
+                return;
+            }
             var startIndex = args.NewStartingIndex > -1 ? args.NewStartingIndex : IndexOf(args.NewItems[0]);
             startIndex = AdjustPositionForHeader(startIndex);
-            var newCount = args.NewItems.Count;
-
-            if (newCount == args.OldItems.Count)
+            
+            int newCount = newItems.Count;
+            int oldCount = oldItems.Count;
+            if (newCount == oldCount)
             {
                 // We are replacing one set of items with a set of equal size; we can do a simple item or range 
                 // notification to the adapter