Precreate the CircleListView (#148)
author유리나/Common Platform Lab(SR)/Staff Engineer/삼성전자 <rina6350.you@samsung.com>
Mon, 17 Feb 2020 06:55:19 +0000 (15:55 +0900)
committer부정균/Common Platform Lab(SR)/Staff Engineer/삼성전자 <jk.pu@samsung.com>
Mon, 17 Feb 2020 06:55:19 +0000 (15:55 +0900)
Tizen.CircularUI/Tizen.Wearable.CircularUI.Forms.Renderer/CircleListViewRenderer.cs
Tizen.CircularUI/Tizen.Wearable.CircularUI.Forms.Renderer/CircleScrollViewRenderer.cs [changed mode: 0755->0644]
Tizen.CircularUI/Tizen.Wearable.CircularUI.Forms.Renderer/NativeFactory.cs
Xamarin.Forms/Xamarin.Forms.Platform.Tizen/Native/NativeFactory.cs
Xamarin.Forms/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
Xamarin.Forms/Xamarin.Forms.Platform.Tizen/Renderers/EntryRenderer.cs
Xamarin.Forms/Xamarin.Forms.Platform.Tizen/Renderers/ImageRenderer.cs

index 4699382..545d0e7 100644 (file)
@@ -23,6 +23,7 @@ using Xamarin.Forms.Platform.Tizen;
 using XForms = Xamarin.Forms.Forms;
 
 using CCircularListView = global::Tizen.Wearable.CircularUI.Forms.CircleListView;
+using System;
 
 [assembly: ExportRenderer(typeof(Tizen.Wearable.CircularUI.Forms.CircleListView), typeof(Tizen.Wearable.CircularUI.Forms.Renderer.CircleListViewRenderer))]
 
@@ -50,8 +51,7 @@ namespace Tizen.Wearable.CircularUI.Forms.Renderer
             if (Control == null)
             {
                 var surface = this.GetSurface();
-                SetNativeControl(new CircleListView(XForms.NativeParent, surface));
-
+                SetNativeControl(NativeFactory.GetNativeControl(typeof(CircleListView), surface) as CircleListView);
                 Control.ItemSelected += OnListViewItemSelected;
             }
 
old mode 100755 (executable)
new mode 100644 (file)
index 4d558d6..5789bd9
@@ -18,6 +18,7 @@ using System;
 using System.ComponentModel;
 using System.Threading.Tasks;
 using ElmSharp;
+using ElmSharp.Wearable;
 using Xamarin.Forms;
 using Xamarin.Forms.Platform.Tizen;
 using Xamarin.Forms.Platform.Tizen.Native;
@@ -51,7 +52,7 @@ namespace Tizen.Wearable.CircularUI.Forms.Renderer
             if (Control == null)
             {
                 var surface = this.GetSurface();
-                SetNativeControl(new ElmSharp.Wearable.CircleScroller(XForms.NativeParent, surface));
+                SetNativeControl(NativeFactory.GetNativeControl(typeof(CircleScroller), surface) as CircleScroller);
                 InitControl();
                 Control.Scrolled += OnScrolled;
                 _scrollCanvas = new Xamarin.Forms.Platform.Tizen.Native.Box(Control);
index d203f01..0eb6216 100644 (file)
@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using ElmSharp;
+using ElmSharp.Wearable;
 using XForms = Xamarin.Forms.Forms;
 
 namespace Tizen.Wearable.CircularUI.Forms.Renderer
@@ -8,6 +9,8 @@ namespace Tizen.Wearable.CircularUI.Forms.Renderer
        class NativeFactory
        {
                static List<NativeCirclePage> circlePages = new List<NativeCirclePage>();
+               static Dictionary<CircleSurface, CircleListView> circleListviews = new Dictionary<CircleSurface, CircleListView>();
+               static Dictionary<CircleSurface, CircleScroller> circleScrollers = new Dictionary<CircleSurface, CircleScroller>();
                const int lfrequency = 3;
 
                public static void PrecreateNatives(EvasObject window)
@@ -17,10 +20,18 @@ namespace Tizen.Wearable.CircularUI.Forms.Renderer
                                var page = new NativeCirclePage(window);
                                page.Hide();
                                circlePages.Add(page);
+
+                               var listview = new CircleListView(window, page.Surface);
+                               listview.Hide();
+                               circleListviews.Add(page.Surface, listview);
+
+                               var scroller = new CircleScroller(window, page.Surface);
+                               scroller.Hide();
+                               circleScrollers.Add(page.Surface, scroller);
                        }
                }
 
-               public static EvasObject GetNativeControl(Type type)
+               public static EvasObject GetNativeControl(Type type, CircleSurface surface = null)
                {
                        if (type == typeof(NativeCirclePage))
                        {
@@ -32,6 +43,24 @@ namespace Tizen.Wearable.CircularUI.Forms.Renderer
                                }
                                return new NativeCirclePage(XForms.NativeParent);
                        }
+                       else if (type == typeof(CircleListView))
+                       {
+                               var listview = circleListviews[surface];
+                               if (listview != null)
+                               {
+                                       return listview;
+                               }
+                               return new CircleListView(XForms.NativeParent, surface);
+                       }
+                       else if (type == typeof(CircleScroller))
+                       {
+                               var scroller = circleScrollers[surface];
+                               if (scroller != null)
+                               {
+                                       return scroller;
+                               }
+                               return new CircleScroller(XForms.NativeParent, surface);
+                       }
                        return Activator.CreateInstance(type, new[] { XForms.NativeParent }) as EvasObject;
                }
        }
index a9211ca..4dc1436 100644 (file)
@@ -8,24 +8,30 @@ namespace Xamarin.Forms.Platform.Tizen.Native
        {
                static List<Label> labels = new List<Label>();
                static List<Image> images = new List<Image>();
+               static List<Watch.WatchButton> buttons = new List<Watch.WatchButton>();
+               static List<EditfieldEntry> editfieldEntrys = new List<EditfieldEntry>();
                static List<Canvas> canvases = new List<Canvas>();
                static List<Page> pages = new List<Page>();
-               const int hfrequency = 6;
+               const int hfrequency = 20;
+               const int mfrequency = 6;
                const int lfrequency = 3;
 
                public static void PrecreateNatives(EvasObject window)
                {
                        for (int i = 0; i < hfrequency; i++)
                        {
-                               var label = new Label(window);
-                               label.Hide();
-                               labels.Add(label);
-
                                var image = new Image(window);
                                image.Hide();
                                images.Add(image);
                        }
 
+                       for (int i = 0; i < mfrequency; i++)
+                       {
+                               var label = new Label(window);
+                               label.Hide();
+                               labels.Add(label);
+                       }
+
                        for (int i = 0; i < lfrequency; i++)
                        {
                                var page = new Page(window);
@@ -35,6 +41,14 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                                var canvas = new Canvas(window);
                                canvas.Hide();
                                canvases.Add(canvas);
+
+                               var button = new Native.Watch.WatchButton(window);
+                               button.Hide();
+                               buttons.Add(button);
+
+                               var editfield = new EditfieldEntry(window);
+                               editfield.Hide();
+                               editfieldEntrys.Add(editfield);
                        }
                }
 
@@ -60,6 +74,26 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                                }
                                return new Image(Forms.NativeParent);
                        }
+                       else if (type == typeof(Watch.WatchButton))
+                       {
+                               if (buttons.Count >= 1)
+                               {
+                                       Watch.WatchButton native = buttons[buttons.Count - 1];
+                                       buttons.RemoveAt(buttons.Count - 1);
+                                       return native;
+                               }
+                               return new Watch.WatchButton(Forms.NativeParent);
+                       }
+                       else if (type == typeof(EditfieldEntry))
+                       {
+                               if (editfieldEntrys.Count >= 1)
+                               {
+                                       EditfieldEntry native = editfieldEntrys[editfieldEntrys.Count - 1];
+                                       editfieldEntrys.RemoveAt(editfieldEntrys.Count - 1);
+                                       return native;
+                               }
+                               return new EditfieldEntry(Forms.NativeParent);
+                       }
                        else if (type == typeof(Canvas))
                        {
                                if (canvases.Count >= 1)
@@ -97,10 +131,10 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                                images.RemoveAt(images.Count - 1);
                                native.Unrealize();
                        }
-                       for (int i = 0; i < pages.Count; i++)
+                       for (int i = 0; i < buttons.Count; i++)
                        {
-                               Page native = pages[pages.Count - 1];
-                               pages.RemoveAt(pages.Count - 1);
+                               Button native = buttons[buttons.Count - 1];
+                               buttons.RemoveAt(buttons.Count - 1);
                                native.Unrealize();
                        }
                        for (int i = 0; i < canvases.Count; i++)
@@ -109,6 +143,12 @@ namespace Xamarin.Forms.Platform.Tizen.Native
                                canvases.RemoveAt(canvases.Count - 1);
                                native.Unrealize();
                        }
+                       for (int i = 0; i < pages.Count; i++)
+                       {
+                               Page native = pages[pages.Count - 1];
+                               pages.RemoveAt(pages.Count - 1);
+                               native.Unrealize();
+                       }
                }
        }
 }
\ No newline at end of file
index 71d6d8a..184aff6 100644 (file)
@@ -32,7 +32,7 @@ namespace Xamarin.Forms.Platform.Tizen
 
                protected virtual EButton CreateNativeControl()
                {
-                       return new Native.Watch.WatchButton(Forms.NativeParent);
+                       return NativeFactory.GetNativeControl(typeof(Native.Watch.WatchButton)) as Native.Watch.WatchButton;
                }
 
                protected override Size MinimumSize()
index 4a0d88d..85c7d11 100644 (file)
@@ -1,4 +1,5 @@
 using System;
+using Xamarin.Forms.Platform.Tizen.Native;
 using IEntry = Xamarin.Forms.Platform.Tizen.Native.IEntry;
 using EEntry = ElmSharp.Entry;
 using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Entry;
@@ -53,10 +54,9 @@ namespace Xamarin.Forms.Platform.Tizen
 
                protected virtual EEntry CreateNativeControl()
                {
-                       return new Native.EditfieldEntry(Forms.NativeParent)
-                       {
-                               IsSingleLine = true,
-                       };
+                       var entry = NativeFactory.GetNativeControl(typeof(Native.EditfieldEntry)) as Native.EditfieldEntry;
+                       entry.IsSingleLine = true;
+                       return entry;
                }
 
                protected override void Dispose(bool disposing)
index 1fcfe75..1d40f67 100644 (file)
@@ -21,7 +21,8 @@ namespace Xamarin.Forms.Platform.Tizen
                {
                        if (Control == null)
                        {
-                               SetNativeControl(new Native.Image(Forms.NativeParent));
+                               var image = NativeFactory.GetNativeControl(typeof(Native.Image)) as Native.Image;
+                               SetNativeControl(image);
                        }
                        base.OnElementChanged(e);
                }