From ccc823e213ed78d5ebb4738cac2782ecf28180eb Mon Sep 17 00:00:00 2001 From: huiyueun <35286162+huiyueun@users.noreply.github.com> Date: Mon, 29 Jul 2019 16:22:18 +0900 Subject: [PATCH] [NUI] Fix Svace issue (#949) * [NUI] Fix Svace issue Signed-off-by: huiyu.eun * delete unused file --- src/Tizen.NUI.CommonUI/Controls/DropDown.cs | 10 ++- .../FlexibleView/LinearLayoutManager.cs | 70 ++++++++++++------- src/Tizen.NUI.CommonUI/Controls/Tab.cs | 2 +- src/Tizen.NUI.CommonUI/Controls/Toast.cs | 54 ++++++++------ .../internal/Xaml/PruneIgnoredNodesVisitor.cs | 2 +- 5 files changed, 86 insertions(+), 52 deletions(-) diff --git a/src/Tizen.NUI.CommonUI/Controls/DropDown.cs b/src/Tizen.NUI.CommonUI/Controls/DropDown.cs index 561289e67..bccd1b68b 100755 --- a/src/Tizen.NUI.CommonUI/Controls/DropDown.cs +++ b/src/Tizen.NUI.CommonUI/Controls/DropDown.cs @@ -2021,14 +2021,20 @@ namespace Tizen.NUI.CommonUI { listItemView.IconResourceUrl = listItemData.IconResourceUrl; listItemView.IconSize2D = listItemData.IconSize2D; - listItemView.IconPosition2D = new Position2D(listItemData.IconPosition2D.X, (listItemView.Size2D.Height - listItemView.IconSize2D.Height) / 2); + if (listItemView.IconSize2D != null) + { + listItemView.IconPosition2D = new Position2D(listItemData.IconPosition2D.X, (listItemView.Size2D.Height - listItemView.IconSize2D.Height) / 2); + } } if (listItemData.CheckImageResourceUrl != null) { listItemView.CheckResourceUrl = listItemData.CheckImageResourceUrl; listItemView.CheckImageSize2D = listItemData.CheckImageSize2D; - listItemView.CheckPosition2D = new Position2D(listItemView.Size2D.Width - listItemData.CheckImageRightSpace - listItemView.CheckImageSize2D.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize2D.Height) / 2); + if (listItemView.CheckImageSize2D != null) + { + listItemView.CheckPosition2D = new Position2D(listItemView.Size2D.Width - listItemData.CheckImageRightSpace - listItemView.CheckImageSize2D.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize2D.Height) / 2); + } } listItemView.IsSelected = listItemData.IsSelected; diff --git a/src/Tizen.NUI.CommonUI/Controls/FlexibleView/LinearLayoutManager.cs b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/LinearLayoutManager.cs index b9700edc9..249afa6c8 100755 --- a/src/Tizen.NUI.CommonUI/Controls/FlexibleView/LinearLayoutManager.cs +++ b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/LinearLayoutManager.cs @@ -610,6 +610,10 @@ namespace Tizen.NUI.CommonUI } FlexibleView.ViewHolder anchorChild = FindFirstCompleteVisibleItemView(); + if (anchorChild != null) + { + return false; + } anchorInfo.Position = anchorChild.LayoutPosition; anchorInfo.Coordinate = mOrientationHelper.GetViewHolderStart(anchorChild); @@ -721,26 +725,32 @@ namespace Tizen.NUI.CommonUI FlexibleView.ViewHolder child = GetChildClosestToEnd(); //Log.Fatal("TV.FLUX.Component", $"==========> child:{child.LayoutGroupIndex}-{child.LayoutItemIndex} childEnd:{orientationHelper.GetItemEnd(child)} # {orientationHelper.GetEnd()}"); - if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderEnd(child) + scrolled < mOrientationHelper.GetEnd()) + if (child != null) { - layoutState.Available = MAX_SCROLL_FACTOR * mOrientationHelper.GetTotalSpace(); - layoutState.Extra = 0; - layoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN; - layoutState.Recycle = false; - Fill(recycler, layoutState, true, immediate); + if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderEnd(child) + scrolled < mOrientationHelper.GetEnd()) + { + layoutState.Available = MAX_SCROLL_FACTOR * mOrientationHelper.GetTotalSpace(); + layoutState.Extra = 0; + layoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN; + layoutState.Recycle = false; + Fill(recycler, layoutState, true, immediate); + } } } else { FlexibleView.ViewHolder child = GetChildClosestToStart(); - if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderStart(child) + scrolled > 0) + if (child != null) { - layoutState.Available = MAX_SCROLL_FACTOR * mOrientationHelper.GetTotalSpace(); - layoutState.Extra = 0; - layoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN; - layoutState.Recycle = false; - Fill(recycler, layoutState, true, immediate); + if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderStart(child) + scrolled > 0) + { + layoutState.Available = MAX_SCROLL_FACTOR * mOrientationHelper.GetTotalSpace(); + layoutState.Extra = 0; + layoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN; + layoutState.Recycle = false; + Fill(recycler, layoutState, true, immediate); + } } } } @@ -866,32 +876,38 @@ namespace Tizen.NUI.CommonUI { mLayoutState.Extra = 0; mLayoutState.LayoutDirection = layoutDirection; - float scrollingOffset; + float scrollingOffset = 0.0f; if (layoutDirection == LayoutState.LAYOUT_END) { mLayoutState.Extra += mOrientationHelper.GetEndPadding(); // get the first child in the direction we are going FlexibleView.ViewHolder child = GetChildClosestToEnd(); - // the direction in which we are traversing children - mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_HEAD - : LayoutState.ITEM_DIRECTION_TAIL; - mLayoutState.CurrentPosition = child.LayoutPosition + mLayoutState.ItemDirection; - mLayoutState.Offset = mOrientationHelper.GetViewHolderEnd(child); - // calculate how much we can scroll without adding new children (independent of layout) - scrollingOffset = mOrientationHelper.GetViewHolderEnd(child) - - mOrientationHelper.GetEndAfterPadding(); + if (child != null) + { + // the direction in which we are traversing children + mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_HEAD + : LayoutState.ITEM_DIRECTION_TAIL; + mLayoutState.CurrentPosition = child.LayoutPosition + mLayoutState.ItemDirection; + mLayoutState.Offset = mOrientationHelper.GetViewHolderEnd(child); + // calculate how much we can scroll without adding new children (independent of layout) + scrollingOffset = mOrientationHelper.GetViewHolderEnd(child) + - mOrientationHelper.GetEndAfterPadding(); + } } else { mLayoutState.Extra += mOrientationHelper.GetStartAfterPadding(); FlexibleView.ViewHolder child = GetChildClosestToStart(); - mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_TAIL - : LayoutState.ITEM_DIRECTION_HEAD; - mLayoutState.CurrentPosition = child.LayoutPosition + mLayoutState.ItemDirection; - mLayoutState.Offset = mOrientationHelper.GetViewHolderStart(child); - scrollingOffset = -mOrientationHelper.GetViewHolderStart(child) - + mOrientationHelper.GetStartAfterPadding(); + if (child != null) + { + mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_TAIL + : LayoutState.ITEM_DIRECTION_HEAD; + mLayoutState.CurrentPosition = child.LayoutPosition + mLayoutState.ItemDirection; + mLayoutState.Offset = mOrientationHelper.GetViewHolderStart(child); + scrollingOffset = -mOrientationHelper.GetViewHolderStart(child) + + mOrientationHelper.GetStartAfterPadding(); + } } mLayoutState.Available = requiredSpace; if (canUseExistingSpace) diff --git a/src/Tizen.NUI.CommonUI/Controls/Tab.cs b/src/Tizen.NUI.CommonUI/Controls/Tab.cs index ecc97f680..6e6e49fc6 100755 --- a/src/Tizen.NUI.CommonUI/Controls/Tab.cs +++ b/src/Tizen.NUI.CommonUI/Controls/Tab.cs @@ -569,7 +569,7 @@ namespace Tizen.NUI.CommonUI int w = Size2D.Width; for (int i = 0; i < totalNum; i++) { - preW = itemList[i].TextItem.NaturalSize2D.Width; + preW = (itemList[i].TextItem.NaturalSize2D != null ? itemList[i].TextItem.NaturalSize2D.Width : 0); itemList[i].Position2D.X = w - preW - preX; itemList[i].Size2D.Width = preW; preX = w - itemList[i].Position2D.X + itemGap; diff --git a/src/Tizen.NUI.CommonUI/Controls/Toast.cs b/src/Tizen.NUI.CommonUI/Controls/Toast.cs index 8c3685bb3..9680ba65e 100755 --- a/src/Tizen.NUI.CommonUI/Controls/Toast.cs +++ b/src/Tizen.NUI.CommonUI/Controls/Toast.cs @@ -212,13 +212,16 @@ namespace Tizen.NUI.CommonUI if (null != value) { CreateBackgroundAttributes(); - if (null == toastAttributes.BackgroundImageAttributes?.ResourceUrl) - { - toastAttributes.BackgroundImageAttributes.ResourceUrl = new StringSelector(); - } - - toastAttributes.BackgroundImageAttributes.ResourceUrl.All = value; - SetToastBackground(); + if (toastAttributes.BackgroundImageAttributes != null) + { + if (null == toastAttributes.BackgroundImageAttributes?.ResourceUrl) + { + toastAttributes.BackgroundImageAttributes.ResourceUrl = new StringSelector(); + } + + toastAttributes.BackgroundImageAttributes.ResourceUrl.All = value; + SetToastBackground(); + } } } } @@ -240,12 +243,15 @@ namespace Tizen.NUI.CommonUI if (null != value) { CreateBackgroundAttributes(); - if (null == toastAttributes.BackgroundImageAttributes.Border) + if (toastAttributes.BackgroundImageAttributes != null) { - toastAttributes.BackgroundImageAttributes.Border = new RectangleSelector(); + if (null == toastAttributes.BackgroundImageAttributes.Border) + { + toastAttributes.BackgroundImageAttributes.Border = new RectangleSelector(); + } + toastAttributes.BackgroundImageAttributes.Border.All = value; + SetToastBackground(); } - toastAttributes.BackgroundImageAttributes.Border.All = value; - SetToastBackground(); } } } @@ -532,23 +538,29 @@ namespace Tizen.NUI.CommonUI private void SetToastText() { - for (int i = 0; i < textLabels?.Length; i++) + if (textLabels != null) { - if (null != textLabels[i]) + for (int i = 0; i < textLabels?.Length; i++) { - this.Remove(textLabels[i]); - textLabels[i].Dispose(); - textLabels[i] = null; + if (null != textLabels[i]) + { + this.Remove(textLabels[i]); + textLabels[i].Dispose(); + textLabels[i] = null; + } } } textLabels = new TextLabel[textArray.Length]; - for (int i = 0; i < textArray.Length; i++) + if (textLabels != null) { - textLabels[i] = new TextLabel(); - textLabels[i].Text = textArray[i]; - textLabels[i].BackgroundColor = Color.Blue; - this.Add(textLabels[i]); + for (int i = 0; i < textArray.Length; i++) + { + textLabels[i] = new TextLabel(); + textLabels[i].Text = textArray[i]; + textLabels[i].BackgroundColor = Color.Blue; + this.Add(textLabels[i]); + } } } diff --git a/src/Tizen.NUI/src/internal/Xaml/PruneIgnoredNodesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/PruneIgnoredNodesVisitor.cs index 8c025e582..90fe6097c 100755 --- a/src/Tizen.NUI/src/internal/Xaml/PruneIgnoredNodesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/PruneIgnoredNodesVisitor.cs @@ -22,7 +22,7 @@ namespace Tizen.NUI.Xaml continue; if (!propertyName.Equals(XamlParser.McUri, "Ignorable")) continue; - (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List())).AddRange(propertyValue.Split(',')); + (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List()))?.AddRange(propertyValue.Split(',')); } foreach (var propertyKvp in node.Properties.ToList()) -- 2.34.1