From: Jay Cho Date: Mon, 23 Mar 2020 08:01:33 +0000 (+0900) Subject: [ElmSharp] Add ElmSharp.Wearable preloading (#1465) X-Git-Tag: accepted/tizen/unified/20210219.040944~818 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=05efe285a4a66c6383e99ac9331236144744e903;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [ElmSharp] Add ElmSharp.Wearable preloading (#1465) * Add ElmSharp.Wearable preloading * Update method name that calls Wearable preload * Add more features on PreloadedWindow for CricleSurface --- diff --git a/src/ElmSharp.Wearable/ElmSharp.Wearable/Preload.cs b/src/ElmSharp.Wearable/ElmSharp.Wearable/Preload.cs new file mode 100644 index 0000000..8013409 --- /dev/null +++ b/src/ElmSharp.Wearable/ElmSharp.Wearable/Preload.cs @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace ElmSharp.Wearable +{ + static class Preload + { + static public void WarmupWidgets(PreloadedWindow win) + { + var surface = new CircleSurface(win.BaseConformant); + win.BaseCircleSurface = surface; + new CircleDateTimeSelector(win, surface).Unrealize(); + new CircleProgressBar(win, surface).Unrealize(); + new CircleScroller(win, surface).Unrealize(); + new CircleSlider(win, surface).Unrealize(); + new CircleSpinner(win, surface).Unrealize(); + new MoreOption(win).Unrealize(); + } + } +} diff --git a/src/ElmSharp/ElmSharp/PreloadedWindow.cs b/src/ElmSharp/ElmSharp/PreloadedWindow.cs index 64c4317..8890506 100644 --- a/src/ElmSharp/ElmSharp/PreloadedWindow.cs +++ b/src/ElmSharp/ElmSharp/PreloadedWindow.cs @@ -14,13 +14,21 @@ * limitations under the License. */ +using System; +using System.ComponentModel; +using System.Reflection; + namespace ElmSharp { - internal class PreloadedWindow : Window + /// + /// Pre-created window which prepares features that takes time in advance. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class PreloadedWindow : Window { static PreloadedWindow s_precreated; - public PreloadedWindow(bool useBaseLayout=true) : base("PreloadWindow") + internal PreloadedWindow(bool useBaseLayout=true) : base("PreloadWindow") { s_precreated = this; if (useBaseLayout) @@ -29,6 +37,11 @@ namespace ElmSharp BackButtonPressed += DummyHandler; BackButtonPressed -= DummyHandler; void DummyHandler(object sender, System.EventArgs e) { } + + if (Elementary.GetProfile() == "wearable") + { + WarmupWearableWidgets(); + } } public Layout BaseLayout @@ -37,9 +50,23 @@ namespace ElmSharp protected set; } + public Conformant BaseConformant + { + get; + protected set; + } + + public object BaseCircleSurface + { + get; + set; + } + + public void InitializeBaseLayout() { var conformant = new Conformant(this); + BaseConformant = conformant; conformant.Show(); var layout = new Layout(conformant); @@ -69,6 +96,21 @@ namespace ElmSharp //TODO: Consider to call Image.LoadAsync() } + public void WarmupWearableWidgets() + { + try + { + Assembly assem = Assembly.Load("ElmSharp.Wearable"); + var type = assem.GetType("ElmSharp.Wearable.Preload"); + type.GetMethod("WarmupWidgets", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { this }); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + Console.WriteLine("Fail to preload ElmSharp.Wearable"); + } + } + public static PreloadedWindow GetInstance() { var instance = s_precreated;