From: Eunki, Hong Date: Mon, 6 Mar 2023 14:20:49 +0000 (+0900) Subject: [NUI] Remove duplicate URL settup X-Git-Tag: submit/tizen/20230307.085137~1^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1ecd75e15b7992461ce5edd61021b3e79e736040;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Remove duplicate URL settup When we create ImageView with url, It will create image visual twice. To avoid this situation, make we replace internal url value for creation time. And also, setup some missing values when we inputed desired size. Signed-off-by: Eunki, Hong --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index 295c04c5a..7ef96639a 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -37,6 +37,22 @@ namespace Tizen.NUI.BaseComponents private EventHandler _resourceLoadedEventHandler; private _resourceLoadedCallbackType _resourceLoadedCallback; + /// + /// Convert non-null string that some keyword change as application specific directory. + /// + /// Inputed and replaced after this function finished + /// Replaced url + private static string ConvertResourceUrl(ref string value) + { + value ??= ""; + if (value.StartsWith("*Resource*")) + { + string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource; + value = value.Replace("*Resource*", resource); + } + return value; + } + // Collection of image-sensitive properties. private static readonly List cachedImagePropertyKeyList = new List { Visual.Property.Type, @@ -101,9 +117,9 @@ namespace Tizen.NUI.BaseComponents /// /// The URL of the image resource to display. /// 3 - public ImageView(string url) : this(Interop.ImageView.New(url), true) + public ImageView(string url) : this(Interop.ImageView.New(ConvertResourceUrl(ref url)), true) { - ResourceUrl = url; + _resourceUrl = url; if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -115,16 +131,18 @@ namespace Tizen.NUI.BaseComponents /// false : Not displayed (hidden), true : displayed (shown) /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI). [EditorBrowsable(EditorBrowsableState.Never)] - public ImageView(string url, bool shown) : this(Interop.ImageView.New(url), true) + public ImageView(string url, bool shown) : this(Interop.ImageView.New(ConvertResourceUrl(ref url)), true) { - ResourceUrl = url; + _resourceUrl = url; if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); SetVisible(shown); } - internal ImageView(string url, Uint16Pair size, bool shown = true) : this(Interop.ImageView.New(url, Uint16Pair.getCPtr(size)), true) + internal ImageView(string url, Uint16Pair size, bool shown = true) : this(Interop.ImageView.New(ConvertResourceUrl(ref url), Uint16Pair.getCPtr(size)), true) { - ResourceUrl = url; + _resourceUrl = url; + _desired_width = size?.GetWidth() ?? -1; + _desired_height = size?.GetHeight() ?? -1; if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); if (!shown) @@ -620,10 +638,10 @@ namespace Tizen.NUI.BaseComponents return; } - Interop.ImageView.SetImage(SwigCPtr, url); + Interop.ImageView.SetImage(SwigCPtr, ConvertResourceUrl(ref url)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - ResourceUrl = url; + _resourceUrl = url; } /// @@ -1166,10 +1184,12 @@ namespace Tizen.NUI.BaseComponents return; } - Interop.ImageView.SetImage(SwigCPtr, url, Uint16Pair.getCPtr(size)); + Interop.ImageView.SetImage(SwigCPtr, ConvertResourceUrl(ref url), Uint16Pair.getCPtr(size)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - ResourceUrl = url; + _resourceUrl = url; + _desired_width = size?.GetWidth() ?? -1; + _desired_height = size?.GetHeight() ?? -1; } internal ViewResourceReadySignal ResourceReadySignal(View view) @@ -1277,13 +1297,7 @@ namespace Tizen.NUI.BaseComponents private void SetResourceUrl(string value) { - value = (value == null ? "" : value); - if (value.StartsWith("*Resource*")) - { - string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource; - value = value.Replace("*Resource*", resource); - } - if(_resourceUrl != value) + if(_resourceUrl != ConvertResourceUrl(ref value)) { _resourceUrl = value; if(string.IsNullOrEmpty(_resourceUrl))