[NUI] add null check in collectionview
authorEverLEEst(SangHyeon Lee) <sh10233.lee@samsung.com>
Tue, 9 Nov 2021 06:39:15 +0000 (15:39 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 11 Nov 2021 06:23:09 +0000 (15:23 +0900)
null value is abnormal in collectionview,
but adding null value check for code management.

src/Tizen.NUI.Components/Controls/RecyclerView/CollectionView.cs
src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.Internal.cs
src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.cs

index e4d7f6d..0e89ad1 100755 (executable)
@@ -601,7 +601,7 @@ namespace Tizen.NUI.Components
             else
             {
                 // If this is not first focus, request next focus to Layouter
-                nextFocusedView = ItemsLayouter.RequestNextFocusableView(currentFocusedView, direction, loopEnabled);
+                nextFocusedView = ItemsLayouter?.RequestNextFocusableView(currentFocusedView, direction, loopEnabled);
             }
 
             if (nextFocusedView != null)
@@ -934,6 +934,8 @@ namespace Tizen.NUI.Components
                 else
                 {
                     item = base.RealizeItem(index);
+                    if (item == null)
+                        throw new Exception("Item realize failed by Null content return.");
                     item.ParentGroup = InternalItemSource.GetGroupParent(index);
                 }
             }
@@ -942,6 +944,9 @@ namespace Tizen.NUI.Components
                 item = base.RealizeItem(index);
             }
 
+            if (item == null)
+                throw new Exception("Item realize failed by Null content return.");
+
             switch (SelectionMode)
             {
                 case ItemSelectionMode.Single:
index b3df782..e995132 100755 (executable)
@@ -106,7 +106,7 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected override bool HandleControlStateOnTouch(Touch touch)
         {
-            if (!IsEnabled || null == touch)
+            if (!IsEnabled || null == touch || null == BindingContext)
             {
                 return false;
             }
index 3def06b..c4ee1bb 100755 (executable)
@@ -191,7 +191,7 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         public override bool OnKey(Key key)
         {
-            if (!IsEnabled || null == key)
+            if (!IsEnabled || null == key || null == BindingContext)
             {
                 return false;
             }