Skip to content

Commit ccc823e

Browse files
huiyueundongsug-song
authored andcommitted
[NUI] Fix Svace issue (Samsung#949)
* [NUI] Fix Svace issue Signed-off-by: huiyu.eun <[email protected]> * delete unused file
1 parent c604628 commit ccc823e

File tree

5 files changed

+86
-52
lines changed

5 files changed

+86
-52
lines changed

src/Tizen.NUI.CommonUI/Controls/DropDown.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -2021,14 +2021,20 @@ public override void OnBindViewHolder(FlexibleView.ViewHolder holder, int positi
20212021
{
20222022
listItemView.IconResourceUrl = listItemData.IconResourceUrl;
20232023
listItemView.IconSize2D = listItemData.IconSize2D;
2024-
listItemView.IconPosition2D = new Position2D(listItemData.IconPosition2D.X, (listItemView.Size2D.Height - listItemView.IconSize2D.Height) / 2);
2024+
if (listItemView.IconSize2D != null)
2025+
{
2026+
listItemView.IconPosition2D = new Position2D(listItemData.IconPosition2D.X, (listItemView.Size2D.Height - listItemView.IconSize2D.Height) / 2);
2027+
}
20252028
}
20262029

20272030
if (listItemData.CheckImageResourceUrl != null)
20282031
{
20292032
listItemView.CheckResourceUrl = listItemData.CheckImageResourceUrl;
20302033
listItemView.CheckImageSize2D = listItemData.CheckImageSize2D;
2031-
listItemView.CheckPosition2D = new Position2D(listItemView.Size2D.Width - listItemData.CheckImageRightSpace - listItemView.CheckImageSize2D.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize2D.Height) / 2);
2034+
if (listItemView.CheckImageSize2D != null)
2035+
{
2036+
listItemView.CheckPosition2D = new Position2D(listItemView.Size2D.Width - listItemData.CheckImageRightSpace - listItemView.CheckImageSize2D.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize2D.Height) / 2);
2037+
}
20322038
}
20332039

20342040
listItemView.IsSelected = listItemData.IsSelected;

src/Tizen.NUI.CommonUI/Controls/FlexibleView/LinearLayoutManager.cs

+43-27
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,10 @@ private bool UpdateAnchorFromChildren(FlexibleView.Recycler recycler, AnchorInfo
610610
}
611611

612612
FlexibleView.ViewHolder anchorChild = FindFirstCompleteVisibleItemView();
613+
if (anchorChild != null)
614+
{
615+
return false;
616+
}
613617
anchorInfo.Position = anchorChild.LayoutPosition;
614618
anchorInfo.Coordinate = mOrientationHelper.GetViewHolderStart(anchorChild);
615619

@@ -721,26 +725,32 @@ private void Cache(FlexibleView.Recycler recycler, LayoutState layoutState, bool
721725
FlexibleView.ViewHolder child = GetChildClosestToEnd();
722726
//Log.Fatal("TV.FLUX.Component", $"==========> child:{child.LayoutGroupIndex}-{child.LayoutItemIndex} childEnd:{orientationHelper.GetItemEnd(child)} # {orientationHelper.GetEnd()}");
723727

724-
if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderEnd(child) + scrolled < mOrientationHelper.GetEnd())
728+
if (child != null)
725729
{
726-
layoutState.Available = MAX_SCROLL_FACTOR * mOrientationHelper.GetTotalSpace();
727-
layoutState.Extra = 0;
728-
layoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN;
729-
layoutState.Recycle = false;
730-
Fill(recycler, layoutState, true, immediate);
730+
if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderEnd(child) + scrolled < mOrientationHelper.GetEnd())
731+
{
732+
layoutState.Available = MAX_SCROLL_FACTOR * mOrientationHelper.GetTotalSpace();
733+
layoutState.Extra = 0;
734+
layoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN;
735+
layoutState.Recycle = false;
736+
Fill(recycler, layoutState, true, immediate);
737+
}
731738
}
732739
}
733740
else
734741
{
735742
FlexibleView.ViewHolder child = GetChildClosestToStart();
736743

737-
if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderStart(child) + scrolled > 0)
744+
if (child != null)
738745
{
739-
layoutState.Available = MAX_SCROLL_FACTOR * mOrientationHelper.GetTotalSpace();
740-
layoutState.Extra = 0;
741-
layoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN;
742-
layoutState.Recycle = false;
743-
Fill(recycler, layoutState, true, immediate);
746+
if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderStart(child) + scrolled > 0)
747+
{
748+
layoutState.Available = MAX_SCROLL_FACTOR * mOrientationHelper.GetTotalSpace();
749+
layoutState.Extra = 0;
750+
layoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN;
751+
layoutState.Recycle = false;
752+
Fill(recycler, layoutState, true, immediate);
753+
}
744754
}
745755
}
746756
}
@@ -866,32 +876,38 @@ private void UpdateLayoutState(int layoutDirection, float requiredSpace, bool ca
866876
{
867877
mLayoutState.Extra = 0;
868878
mLayoutState.LayoutDirection = layoutDirection;
869-
float scrollingOffset;
879+
float scrollingOffset = 0.0f;
870880
if (layoutDirection == LayoutState.LAYOUT_END)
871881
{
872882
mLayoutState.Extra += mOrientationHelper.GetEndPadding();
873883
// get the first child in the direction we are going
874884
FlexibleView.ViewHolder child = GetChildClosestToEnd();
875-
// the direction in which we are traversing children
876-
mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_HEAD
877-
: LayoutState.ITEM_DIRECTION_TAIL;
878-
mLayoutState.CurrentPosition = child.LayoutPosition + mLayoutState.ItemDirection;
879-
mLayoutState.Offset = mOrientationHelper.GetViewHolderEnd(child);
880-
// calculate how much we can scroll without adding new children (independent of layout)
881-
scrollingOffset = mOrientationHelper.GetViewHolderEnd(child)
882-
- mOrientationHelper.GetEndAfterPadding();
885+
if (child != null)
886+
{
887+
// the direction in which we are traversing children
888+
mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_HEAD
889+
: LayoutState.ITEM_DIRECTION_TAIL;
890+
mLayoutState.CurrentPosition = child.LayoutPosition + mLayoutState.ItemDirection;
891+
mLayoutState.Offset = mOrientationHelper.GetViewHolderEnd(child);
892+
// calculate how much we can scroll without adding new children (independent of layout)
893+
scrollingOffset = mOrientationHelper.GetViewHolderEnd(child)
894+
- mOrientationHelper.GetEndAfterPadding();
895+
}
883896

884897
}
885898
else
886899
{
887900
mLayoutState.Extra += mOrientationHelper.GetStartAfterPadding();
888901
FlexibleView.ViewHolder child = GetChildClosestToStart();
889-
mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_TAIL
890-
: LayoutState.ITEM_DIRECTION_HEAD;
891-
mLayoutState.CurrentPosition = child.LayoutPosition + mLayoutState.ItemDirection;
892-
mLayoutState.Offset = mOrientationHelper.GetViewHolderStart(child);
893-
scrollingOffset = -mOrientationHelper.GetViewHolderStart(child)
894-
+ mOrientationHelper.GetStartAfterPadding();
902+
if (child != null)
903+
{
904+
mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_TAIL
905+
: LayoutState.ITEM_DIRECTION_HEAD;
906+
mLayoutState.CurrentPosition = child.LayoutPosition + mLayoutState.ItemDirection;
907+
mLayoutState.Offset = mOrientationHelper.GetViewHolderStart(child);
908+
scrollingOffset = -mOrientationHelper.GetViewHolderStart(child)
909+
+ mOrientationHelper.GetStartAfterPadding();
910+
}
895911
}
896912
mLayoutState.Available = requiredSpace;
897913
if (canUseExistingSpace)

src/Tizen.NUI.CommonUI/Controls/Tab.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ protected virtual void LayoutChild()
569569
int w = Size2D.Width;
570570
for (int i = 0; i < totalNum; i++)
571571
{
572-
preW = itemList[i].TextItem.NaturalSize2D.Width;
572+
preW = (itemList[i].TextItem.NaturalSize2D != null ? itemList[i].TextItem.NaturalSize2D.Width : 0);
573573
itemList[i].Position2D.X = w - preW - preX;
574574
itemList[i].Size2D.Width = preW;
575575
preX = w - itemList[i].Position2D.X + itemGap;

src/Tizen.NUI.CommonUI/Controls/Toast.cs

+33-21
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,16 @@ public string BackgroundImageURL
212212
if (null != value)
213213
{
214214
CreateBackgroundAttributes();
215-
if (null == toastAttributes.BackgroundImageAttributes?.ResourceUrl)
216-
{
217-
toastAttributes.BackgroundImageAttributes.ResourceUrl = new StringSelector();
218-
}
219-
220-
toastAttributes.BackgroundImageAttributes.ResourceUrl.All = value;
221-
SetToastBackground();
215+
if (toastAttributes.BackgroundImageAttributes != null)
216+
{
217+
if (null == toastAttributes.BackgroundImageAttributes?.ResourceUrl)
218+
{
219+
toastAttributes.BackgroundImageAttributes.ResourceUrl = new StringSelector();
220+
}
221+
222+
toastAttributes.BackgroundImageAttributes.ResourceUrl.All = value;
223+
SetToastBackground();
224+
}
222225
}
223226
}
224227
}
@@ -240,12 +243,15 @@ public Rectangle BackgroundImageBorder
240243
if (null != value)
241244
{
242245
CreateBackgroundAttributes();
243-
if (null == toastAttributes.BackgroundImageAttributes.Border)
246+
if (toastAttributes.BackgroundImageAttributes != null)
244247
{
245-
toastAttributes.BackgroundImageAttributes.Border = new RectangleSelector();
248+
if (null == toastAttributes.BackgroundImageAttributes.Border)
249+
{
250+
toastAttributes.BackgroundImageAttributes.Border = new RectangleSelector();
251+
}
252+
toastAttributes.BackgroundImageAttributes.Border.All = value;
253+
SetToastBackground();
246254
}
247-
toastAttributes.BackgroundImageAttributes.Border.All = value;
248-
SetToastBackground();
249255
}
250256
}
251257
}
@@ -532,23 +538,29 @@ private void OnVisibilityChanged(object sender, VisibilityChangedEventArgs e)
532538

533539
private void SetToastText()
534540
{
535-
for (int i = 0; i < textLabels?.Length; i++)
541+
if (textLabels != null)
536542
{
537-
if (null != textLabels[i])
543+
for (int i = 0; i < textLabels?.Length; i++)
538544
{
539-
this.Remove(textLabels[i]);
540-
textLabels[i].Dispose();
541-
textLabels[i] = null;
545+
if (null != textLabels[i])
546+
{
547+
this.Remove(textLabels[i]);
548+
textLabels[i].Dispose();
549+
textLabels[i] = null;
550+
}
542551
}
543552
}
544553

545554
textLabels = new TextLabel[textArray.Length];
546-
for (int i = 0; i < textArray.Length; i++)
555+
if (textLabels != null)
547556
{
548-
textLabels[i] = new TextLabel();
549-
textLabels[i].Text = textArray[i];
550-
textLabels[i].BackgroundColor = Color.Blue;
551-
this.Add(textLabels[i]);
557+
for (int i = 0; i < textArray.Length; i++)
558+
{
559+
textLabels[i] = new TextLabel();
560+
textLabels[i].Text = textArray[i];
561+
textLabels[i].BackgroundColor = Color.Blue;
562+
this.Add(textLabels[i]);
563+
}
552564
}
553565
}
554566

src/Tizen.NUI/src/internal/Xaml/PruneIgnoredNodesVisitor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void Visit(ElementNode node, INode parentNode)
2222
continue;
2323
if (!propertyName.Equals(XamlParser.McUri, "Ignorable"))
2424
continue;
25-
(parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string>())).AddRange(propertyValue.Split(','));
25+
(parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string>()))?.AddRange(propertyValue.Split(','));
2626
}
2727

2828
foreach (var propertyKvp in node.Properties.ToList())

0 commit comments

Comments
 (0)