protected override Xamarin.Forms.Platform.Tizen.Native.ListView CreateNativeControl()
{
- return _listView = new WatchListView(XForms.NativeParent, this.GetSurface());
+ return _listView = NativeFactory.GetNativeControl(typeof(WatchListView), this.GetSurface()) as WatchListView;
}
void UpdateBarColor()
}
protected override Xamarin.Forms.Platform.Tizen.Native.Scroller CreateNativeControl()
- {
- return _scroller = new WatchScroller(XForms.NativeParent, this.GetSurface());
+ {
+ return _scroller = Xamarin.Forms.Platform.Tizen.Native.NativeFactory.GetNativeControl(typeof(WatchScroller), this.GetSurface()) as WatchScroller;
}
void UpdateBarColor()
public static class CircularUIForms
{
[EditorBrowsable(EditorBrowsableState.Never)]
- public static void Preload(object windows)
+ public static void Preload(Xamarin.Forms.Platform.Tizen.PreloadedWindow preloadedWindow)
{
- EvasObject win = windows as EvasObject;
- NativeFactory.PrecreateNatives(win);
+ NativeFactory.PrecreateNatives(preloadedWindow);
}
public static Dictionary<Type, Func<IRegisterable>> StaticHandlers = new Dictionary<Type, Func<IRegisterable>>()
{
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;
+ static Dictionary<CircleSurface, WatchListView> watchListviews = new Dictionary<CircleSurface, WatchListView>();
+ const int lfrequency = 1;
- public static void PrecreateNatives(EvasObject window)
+ public static void PrecreateNatives(Xamarin.Forms.Platform.Tizen.PreloadedWindow preloadedWindow)
{
for (int i = 0; i < lfrequency; i++)
{
- 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);
+ var listview = new WatchListView(preloadedWindow.Window, preloadedWindow.BaseCircleSurface);
+ listview.Hide();
+ watchListviews.Add(preloadedWindow.BaseCircleSurface, listview);
}
}
public static EvasObject GetNativeControl(Type type, CircleSurface surface = null)
{
- if (type == typeof(NativeCirclePage))
- {
- if (circlePages.Count >= 1)
- {
- NativeCirclePage native = circlePages[circlePages.Count - 1];
- circlePages.Remove(native);
- return native;
- }
- return new NativeCirclePage(XForms.NativeParent);
- }
- else if (type == typeof(CircleListView))
+ if (type == typeof(WatchListView))
{
- //if (circleListviews.ContainsKey(surface))
- //{
- // var listview = circleListviews[surface];
- // if (listview != null)
- // {
- // circleListviews.Remove(surface);
- // return listview;
- // }
- //}
- //return new CircleListView(XForms.NativeParent, surface);
- }
- else if (type == typeof(CircleScroller))
- {
- if (circleScrollers.ContainsKey(surface))
+ if (watchListviews.ContainsKey(surface))
{
- var scroller = circleScrollers[surface];
- if (scroller != null)
+ var listview = watchListviews[surface];
+ if (listview != null)
{
- circleScrollers.Remove(surface);
- return scroller;
+ watchListviews.Remove(surface);
+ return listview;
}
}
- return new CircleScroller(XForms.NativeParent, surface);
+ return new WatchListView(XForms.NativeParent, surface);
}
return Activator.CreateInstance(type, new[] { XForms.NativeParent }) as EvasObject;
}
public static void DeleteUnusedNative()
{
- foreach (var item in circlePages)
- {
- item.Unrealize();
- }
- circlePages.Clear();
-
- //foreach (var item in circleListviews)
- //{
- // item.Value.Unrealize();
- //}
- //circleListviews.Clear();
-
- foreach (var item in circleScrollers)
+ foreach (var item in watchListviews)
{
item.Value.Unrealize();
}
- circleScrollers.Clear();
+ watchListviews.Clear();
}
}
}
\ No newline at end of file
PTizen.PreloadedWindow preloadedWindow = new PTizen.PreloadedWindow();
if (preloadedWindow.Window != null)
{
- global::Xamarin.Forms.Platform.Tizen.Native.NativeFactory.PrecreateNatives(preloadedWindow.Window);
- global::Tizen.Wearable.CircularUI.Forms.CircularUIForms.Preload(preloadedWindow.Window);
+ global::Xamarin.Forms.Platform.Tizen.Native.NativeFactory.PrecreateNatives(preloadedWindow);
+ global::Tizen.Wearable.CircularUI.Forms.CircularUIForms.Preload(preloadedWindow);
}
else
{
using System;
using ElmSharp;
+using ElmSharp.Wearable;
using System.Collections.Generic;
namespace Xamarin.Forms.Platform.Tizen.Native
static List<EditfieldEntry> editfieldEntrys = new List<EditfieldEntry>();
static List<Canvas> canvases = new List<Canvas>();
static List<Page> pages = new List<Page>();
+ static Dictionary<CircleSurface, Watch.WatchListView> watchListviews = new Dictionary<CircleSurface, Watch.WatchListView>();
+ static Dictionary<CircleSurface, Watch.WatchScroller> watchScrollers = new Dictionary<CircleSurface, Watch.WatchScroller>();
const int hfrequency = 20;
const int mfrequency = 6;
const int lfrequency = 3;
- public static void PrecreateNatives(EvasObject window)
+ public static void PrecreateNatives(PreloadedWindow preloadedWindow)
{
for (int i = 0; i < hfrequency; i++)
{
- var image = new Image(window);
+ var image = new Image(preloadedWindow.Window);
image.Hide();
images.Add(image);
}
for (int i = 0; i < mfrequency; i++)
{
- var label = new Label(window);
+ var label = new Label(preloadedWindow.Window);
label.Hide();
labels.Add(label);
}
for (int i = 0; i < lfrequency; i++)
{
- var page = new Page(window);
+ var page = new Page(preloadedWindow.Window);
page.Hide();
pages.Add(page);
- var canvas = new Canvas(window);
+ var canvas = new Canvas(preloadedWindow.Window);
canvas.Hide();
canvases.Add(canvas);
- var button = new Native.Watch.WatchButton(window);
+ var button = new Watch.WatchButton(preloadedWindow.Window);
button.Hide();
buttons.Add(button);
- var editfield = new EditfieldEntry(window);
+ var editfield = new EditfieldEntry(preloadedWindow.Window);
editfield.Hide();
editfieldEntrys.Add(editfield);
}
+
+ var listview = new Watch.WatchListView(preloadedWindow.Window, preloadedWindow.BaseCircleSurface);
+ listview.Hide();
+ watchListviews.Add(preloadedWindow.BaseCircleSurface, listview);
+
+ var scroller = new Watch.WatchScroller(preloadedWindow.Window, preloadedWindow.BaseCircleSurface);
+ scroller.Hide();
+ watchScrollers.Add(preloadedWindow.BaseCircleSurface, scroller);
}
- public static EvasObject GetNativeControl(Type type)
+ public static EvasObject GetNativeControl(Type type, CircleSurface surface = null)
{
if (type == typeof(Label))
{
}
return new Page(Forms.NativeParent);
}
+ else if (type == typeof(Watch.WatchListView))
+ {
+ if (watchListviews.ContainsKey(surface))
+ {
+ var listview = watchListviews[surface];
+ if (listview != null)
+ {
+ watchListviews.Remove(surface);
+ return listview;
+ }
+ }
+ return new Watch.WatchListView(Forms.NativeParent, surface);
+ }
+ else if (type == typeof(Watch.WatchScroller))
+ {
+ if (watchScrollers.ContainsKey(surface))
+ {
+ var scroller = watchScrollers[surface];
+ if (scroller != null)
+ {
+ watchScrollers.Remove(surface);
+ return scroller;
+ }
+ }
+ return new Watch.WatchScroller(Forms.NativeParent, surface);
+ }
return Activator.CreateInstance(type, new[] { Forms.NativeParent }) as EvasObject;
}
native.Unrealize();
}
pages.Clear();
+
+ foreach (var item in watchListviews)
+ {
+ item.Value.Unrealize();
+ }
+ watchListviews.Clear();
+
+ foreach (var item in watchScrollers)
+ {
+ item.Value.Unrealize();
+ }
+ watchScrollers.Clear();
}
}
}
\ No newline at end of file
{
if (Device.Idiom == TargetIdiom.Watch)
{
- return new Native.Watch.WatchListView(Forms.NativeParent, Forms.CircleSurface);
+ return Native.NativeFactory.GetNativeControl(typeof(Native.Watch.WatchListView), Forms.CircleSurface) as Native.Watch.WatchListView;
}
else
{
protected virtual NScroller CreateNativeControl()
{
-
if (Device.Idiom == TargetIdiom.Watch)
{
- return new Native.Watch.WatchScroller(Forms.NativeParent, Forms.CircleSurface);
+ return Native.NativeFactory.GetNativeControl(typeof(Native.Watch.WatchScroller), Forms.CircleSurface) as Native.Watch.WatchScroller;
}
else
{