[NUI.Components] Fix svace issues (#1310)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / DropDown.cs
index d4e0b50..745dccf 100755 (executable)
@@ -32,7 +32,7 @@ namespace Tizen.NUI.Components
     {
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create("ListPadding", typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
+        public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create(nameof(ListPadding), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var instance = (DropDown)bindable;
             if (newValue != null)
@@ -48,7 +48,7 @@ namespace Tizen.NUI.Components
         });
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create("SelectedItemIndex", typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
+        public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create(nameof(SelectedItemIndex), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var instance = (DropDown)bindable;
             if (newValue != null)
@@ -68,7 +68,7 @@ namespace Tizen.NUI.Components
         });
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public static readonly BindableProperty ListMarginProperty = BindableProperty.Create("ListMargin", typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
+        public static readonly BindableProperty ListMarginProperty = BindableProperty.Create(nameof(ListMargin), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var instance = (DropDown)bindable;
             if (newValue != null)
@@ -84,7 +84,7 @@ namespace Tizen.NUI.Components
         });
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create("ListRelativeOrientation", typeof(ListOrientation), typeof(DropDown), ListOrientation.Left, propertyChanged: (bindable, oldValue, newValue) =>
+        public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create(nameof(ListRelativeOrientation), typeof(ListOrientation), typeof(DropDown), ListOrientation.Left, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var instance = (DropDown)bindable;
             if (newValue != null)
@@ -100,7 +100,7 @@ namespace Tizen.NUI.Components
         });
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create("SpaceBetweenButtonTextAndIcon", typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
+        public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create(nameof(SpaceBetweenButtonTextAndIcon), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var instance = (DropDown)bindable;
             if (newValue != null)
@@ -120,7 +120,7 @@ namespace Tizen.NUI.Components
         private TextLabel buttonText = null;
         private ImageView listBackgroundImage = null;
         // Component that scrolls the child added to it.
-        private Scrollable scrollable = null;
+        private ScrollableBase scrollableBase = null;
 
         // The LinearLayout container to house the items in the drop down list.
         private View dropDownMenuFullList = null;
@@ -135,6 +135,8 @@ namespace Tizen.NUI.Components
         private int spaceBetweenButtonTextAndIcon = 0;
         private bool itemPressed = false;
 
+        static DropDown() { }
+
         /// <summary>
         /// Creates a new instance of a DropDown.
         /// </summary>
@@ -351,7 +353,7 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void AttachScrollBar(ScrollBar scrollBar)
         {
-            if (scrollable == null)
+            if (scrollableBase == null)
             {
                 return;
             }
@@ -366,7 +368,7 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void DetachScrollBar()
         {
-            if (scrollable == null)
+            if (scrollableBase == null)
             {
                 return;
             }
@@ -387,7 +389,7 @@ namespace Tizen.NUI.Components
                 CreateButton();
 
                 CreateListBackgroundImage();
-                if (null == scrollable) // scrollable used to test of ListContainer Setup invoked already
+                if (null == scrollableBase) // scrollableBase used to test of ListContainer Setup invoked already
                 {
                     SetUpListContainer();
                 }
@@ -406,11 +408,11 @@ namespace Tizen.NUI.Components
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected void UpdateDropDown()
         {
-            if (null == scrollable || null == listBackgroundImage || null == dropDownMenuFullList) return;
+            if (null == scrollableBase || null == listBackgroundImage || null == dropDownMenuFullList) return;
             if (null == Style.ListBackgroundImage.Size) return;
             // Resize and position scrolling list within the drop down list container.  Can be used to position list in relation to the background image.
-            scrollable.Size = Style.ListBackgroundImage.Size - new Size((listPadding.Start + listPadding.End), (listPadding.Top + listPadding.Bottom), 0);
-            scrollable.Position2D = new Position2D(listPadding.Start, listPadding.Top);
+            scrollableBase.Size = Style.ListBackgroundImage.Size - new Size((listPadding.Start + listPadding.End), (listPadding.Top + listPadding.Bottom), 0);
+            scrollableBase.Position2D = new Position2D(listPadding.Start, listPadding.Top);
 
             int listBackgroundImageX = 0;
             int listBackgroundImageY = 0;
@@ -428,6 +430,9 @@ namespace Tizen.NUI.Components
             dropDownMenuFullList?.Layout?.RequestLayout();
         }
 
+        /// <summary>
+        /// update.
+        /// </summary>
         protected override void OnUpdate()
         {
             float iconWidth = 0;
@@ -474,7 +479,7 @@ namespace Tizen.NUI.Components
                 Utility.Dispose(headerText);
                 Utility.Dispose(buttonText);
                 Utility.Dispose(button);
-                Utility.Dispose(scrollable);
+                Utility.Dispose(scrollableBase);
                 Utility.Dispose(dropDownMenuFullList);
                 Utility.Dispose(listBackgroundImage);
             }
@@ -594,13 +599,13 @@ namespace Tizen.NUI.Components
                 Focusable = true,
             };
 
-            scrollable = new Scrollable()
+            scrollableBase = new ScrollableBase()
             {
                 Name = "Scrollable",
             };
-            scrollable.Add(dropDownMenuFullList);
+            scrollableBase.Add(dropDownMenuFullList);
 
-            listBackgroundImage.Add(scrollable);
+            listBackgroundImage.Add(scrollableBase);
             listBackgroundImage.Hide();
         }
 
@@ -686,7 +691,7 @@ namespace Tizen.NUI.Components
                     data.IsSelected = false;
                 }
                 DropDownItemView listItemView = dropDownMenuFullList.GetChildAt((uint)selectedItemIndex) as DropDownItemView;
-                data.IsSelected = false;
+
                 SetListItemToSelected(listItemView);
             }
 
@@ -1464,6 +1469,7 @@ namespace Tizen.NUI.Components
             [EditorBrowsable(EditorBrowsableState.Never)]
             public void BindViewHolder(ViewHolder holder, int position)
             {
+                if (null == holder) return;
                 DropDownDataItem listItemData = itemDataList[position];
                 if(listItemData == null)
                 {
@@ -1541,6 +1547,7 @@ namespace Tizen.NUI.Components
             [EditorBrowsable(EditorBrowsableState.Never)]
             public void OnDestroyViewHolder(ViewHolder holder)
             {
+                if (null == holder) return;
                 if (holder.ItemView != null)
                 {
                     holder.ItemView.Dispose();