Fixes for Analysis Hub SVACE check (#49)
authorMarcin Romaniuk/Tizen Services & IoT (PLT) /SRPOL/Senior Designer/Samsung Electronics <m.romaniuk@samsung.com>
Tue, 25 May 2021 21:03:02 +0000 (23:03 +0200)
committerPiotr Czaja <p.czaja@samsung.com>
Tue, 14 Sep 2021 11:01:34 +0000 (13:01 +0200)
* Fixes for Analysis Hub SVACE check
* review fix: dispose order

Fitness/Controls/ConnectedAnimation.cs
Fitness/Controls/ConnectedTransition.cs
Fitness/Controls/FadeTransition.cs
Fitness/Controls/NinePatchButton.cs
Fitness/FitnessApp.cs

index 594b92f74640e2151baf2bf320e4d2327ed6a3e7..803796d4975b6a37fd8730c3d4dd4a7cacf232ca 100644 (file)
@@ -20,23 +20,28 @@ namespace Fitness.Controls
 
             int idx = Source.GetPropertyIndex(propertyName);
 
-            switch (propertyName)
+            using (var sourcePosition = GetWorldPosition(Source))
+            using (var viewPosition = GetWorldPosition(view))
+            using (var position = sourcePosition - viewPosition)
             {
-                case "Position":
-                    sourceValue = PropertyValue.CreateFromObject(GetWorldPosition(Source) - GetWorldPosition(view));
-                    break;
-                case "PositionX":
-                    sourceValue = PropertyValue.CreateFromObject((GetWorldPosition(Source) - GetWorldPosition(view)).X);
-                    break;
-                case "PositionY":
-                    sourceValue = PropertyValue.CreateFromObject((GetWorldPosition(Source) - GetWorldPosition(view)).Y);
-                    break;
-                case "PositionZ":
-                    sourceValue = PropertyValue.CreateFromObject((GetWorldPosition(Source) - GetWorldPosition(view)).Z);
-                    break;
-                default:
-                    sourceValue = Source.GetProperty(idx);
-                    break;
+                switch (propertyName)
+                {
+                    case "Position":
+                        sourceValue = PropertyValue.CreateFromObject(position);
+                        break;
+                    case "PositionX":
+                        sourceValue = PropertyValue.CreateFromObject(position.X);
+                        break;
+                    case "PositionY":
+                        sourceValue = PropertyValue.CreateFromObject(position.Y);
+                        break;
+                    case "PositionZ":
+                        sourceValue = PropertyValue.CreateFromObject(position.Z);
+                        break;
+                    default:
+                        sourceValue = Source.GetProperty(idx);
+                        break;
+                }
             }
 
             toValue = PropertyValue.CreateFromObject(to);
@@ -46,15 +51,17 @@ namespace Fitness.Controls
 
         private static Position GetWorldPosition(View view)
         {
-            Position position = new Position();
+            float x = 0;
+            float y = 0;
 
             while (view != null)
             {
-                position += view.Position;
+                x += view.Position.X;
+                y += view.Position.Y;
                 view = view.GetParent() as View;
             }
 
-            return position;
+            return new Position(x, y);
         }
 
         private void AnimatePropertyBetween(View view, string propertyName, PropertyValue from, PropertyValue to, Interpolation interpolation, AlphaFunction alphaFunction)
index 3f1c07731a184ccf241376a8f620a24154c14baf..56126a7df44404ac37e8909d9dde04c139172dde 100644 (file)
@@ -65,6 +65,7 @@ namespace Fitness.Controls
         public override void Dispose()
         {
             animation?.Dispose();
+            base.Dispose();
         }
 
         private IConnectedAnimationsContainer FindContainerForView(View view)
index f2d2844491aaf3fa4b23f6139f6565c4dd2b6f42..12e30e41c8bce429ee7a6acc6bbdb01f37e1d28e 100644 (file)
@@ -45,6 +45,7 @@ namespace Fitness.Controls
         public override void Dispose()
         {
             animation?.Dispose();
+            base.Dispose();
         }
 
         private void AnimationFinished(object o, EventArgs args)
index 10f4247b575c1e3f15cbb0ed03f96e4d19c4ee42..767ada6ecd8cf6a1282c8974d7cd9b5ac9f8b275 100644 (file)
@@ -8,6 +8,8 @@ namespace Fitness.Controls
 {
     public class NinePatchButton : Button
     {
+        private Tizen.NUI.NPatchVisual visualMap;
+
         public NinePatchButton()
         {
             this.Relayout += NinePatchButton_Relayout;
@@ -37,25 +39,23 @@ namespace Fitness.Controls
 
         private void UpdateButton(Color color, string url)
         {
-            PropertyMap outputVisualMap = null;
-            if (color != null)
+            if (visualMap == null)
             {
-                outputVisualMap = new Tizen.NUI.NPatchVisual()
-                {
-                    URL = url,
-                    MixColor = color,
-                }.OutputVisualMap;
+                visualMap = new Tizen.NUI.NPatchVisual();
             }
-            else
+
+            if (url != null)
             {
-                outputVisualMap = new Tizen.NUI.NPatchVisual()
-                {
-                    URL = url,
-                }.OutputVisualMap;
+                visualMap.URL = url;
+            }
+
+            if (color != null)
+            {
+                visualMap.MixColor = color;
             }
 
-            this.Background = outputVisualMap;
-            this.OverlayImage.Background = outputVisualMap;
+            Background = visualMap.OutputVisualMap;
+            OverlayImage.Background = visualMap.OutputVisualMap;
         }
 
         private void UpdateButton()
index a1508f13e55b286bc83847bbe13cc329180ae418..6e3d020e1999dbf6380493a8ad9c88467f8d6635 100644 (file)
@@ -9,8 +9,10 @@ namespace Fitness
     {
         public static void Main(string[] args)
         {
-            var app = new FitnessApp();
-            app.Run(args);
+            using (var app = new FitnessApp())
+            {
+                app.Run(args);
+            }
         }
 
         public void Initialize()