2 using Tizen.NUI.BaseComponents;
4 using System.Collections.Generic;
6 namespace Tizen.NUI.Samples
8 using tlog = Tizen.Log;
9 public class LottieAnimationViewDynamicPropertyTest : IExample
12 const int NUM_OF_VIEW = 5;
13 const int TIMER_INTERVAL = 3000;
14 const string tag = "NUITEST";
18 public void Activate()
20 win = NUIApplication.GetDefaultWindow();
24 Size = new Size(win.Size.Width, win.Size.Height, 0),
25 BackgroundColor = Color.Yellow,
26 Layout = new LinearLayout()
28 LinearOrientation = LinearLayout.Orientation.Horizontal,
33 timer = new Timer(TIMER_INTERVAL);
39 bool OnTick(object sender, Timer.TickEventArgs e)
48 //create objects => explicit dispose => create objects => implicit dispose
73 //create objects => implicit dispose => force full GC
95 global::System.Random rand = new global::System.Random();
98 var lav = new LottieAnimationView();
99 lav.Size2D = new Size2D(300, 300);
100 lav.Position2D = new Position2D(rand.Next(10, 1000), rand.Next(10, 1000));
103 lav.URL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "a.json";
107 lav.URL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "done.json";
110 lav.BackgroundColor = Color.White;
114 var ret = lav.GetContentInfo();
115 tlog.Fatal(tag, $"ret.Count {ret.Count}");
116 foreach (var item in ret)
118 tlog.Fatal(tag, $"item:({item.Item1}, {item.Item2}, {item.Item3})");
125 tlog.Debug(tag, "ForceFullGC start");
126 global::System.GC.Collect();
127 global::System.GC.WaitForPendingFinalizers();
128 global::System.GC.Collect();
129 tlog.Debug(tag, "ForceFullGC end");
134 tlog.Debug(tag, $"MakeAll() start");
135 int width = (int)(root.Size.Width / NUM_OF_VIEW);
136 for (int i = 0; i < NUM_OF_VIEW; i++)
138 var lav = new LottieAnimationView();
139 lav.Size2D = new Size2D(width, width);
140 lav.URL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "done.json";
142 lav.BackgroundColor = Color.White;
145 LottieAnimationViewDynamicProperty pro = new LottieAnimationViewDynamicProperty
147 KeyPath = "Shape Layer 1.Ellipse 1.Fill 1",
148 Property = LottieAnimationView.VectorProperty.FillColor,
149 Callback = new Tizen.NUI.BaseComponents.LottieAnimationView.DynamicPropertyCallbackType(OnFillColor),
154 lav.DoActionExtension(pro);
160 pro.Property = LottieAnimationView.VectorProperty.StrokeColor;
161 pro.Callback = new Tizen.NUI.BaseComponents.LottieAnimationView.DynamicPropertyCallbackType(OnStrokColor);
162 lav.DoActionExtension(pro);
168 pro.Property = LottieAnimationView.VectorProperty.StrokeWidth;
169 pro.Callback = new Tizen.NUI.BaseComponents.LottieAnimationView.DynamicPropertyCallbackType(OnStrokWidth);
170 lav.DoActionExtension(pro);
175 pro.KeyPath = "Shape Layer 2.Shape 1";
176 pro.Property = LottieAnimationView.VectorProperty.TransformRotation;
177 pro.Callback = new Tizen.NUI.BaseComponents.LottieAnimationView.DynamicPropertyCallbackType(OnTransformRotation);
178 lav.DoActionExtension(pro);
182 tlog.Debug(tag, $"MakeAll() end");
187 tlog.Debug(tag, $"DisposeAll() start");
188 int childNum = (int)root.ChildCount;
189 for (int i = childNum - 1; i >= 0; i--)
191 var child = root.GetChildAt((uint)i);
198 tlog.Debug(tag, $"DisposeAll() end");
201 void ImplicitDispose()
203 tlog.Debug(tag, $"ImplicitDispose() start");
204 int childNum = (int)root.ChildCount;
205 for (int i = childNum - 1; i >= 0; i--)
207 var child = root.GetChildAt((uint)i);
213 tlog.Debug(tag, $"ImplicitDispose() end");
216 private PropertyValue OnFillColor(int returnType, uint frameNumber)
218 tlog.Debug(tag, $"OnFillColor() returnType={returnType} frameNumber={frameNumber}");
219 if (frameNumber < 60)
221 return new PropertyValue(new Vector3(0, 0, 1));
225 return new PropertyValue(new Vector3(1, 0, 0));
229 private PropertyValue OnStrokColor(int returnType, uint frameNumber)
231 tlog.Debug(tag, $"OnStrokColor() returnType={returnType} frameNumber={frameNumber}");
232 if (frameNumber < 60)
234 return new PropertyValue(new Vector3(1, 0, 1));
238 return new PropertyValue(new Vector3(1, 1, 0));
242 private PropertyValue OnStrokWidth(int returnType, uint frameNumber)
244 tlog.Debug(tag, $"OnStrokWidth() returnType={returnType} frameNumber={frameNumber}");
246 if (frameNumber < 60)
248 return new PropertyValue(2.0f);
252 return new PropertyValue(5.0f);
256 private PropertyValue OnTransformRotation(int returnType, uint frameNumber)
258 tlog.Debug(tag, $"OnTransformRotation() returnType={returnType} frameNumber={frameNumber}");
260 return new PropertyValue(frameNumber * 20.0f);
263 public void Deactivate()