wxr
2022-12-14 a61775710f8c4466db5bfce58af58f886d58edf3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
using AdSupport;
using com.hdl.on;
using Foundation;
using Shared;
using UIKit;
using UserNotifications;
 
 
namespace SharedMethod
{
    public static class SharedMethod
    {
        public static UIApplication sharedApp;
        public static void ChangeSkin ()
        {
                sharedApp.StatusBarStyle = UIStatusBarStyle.Default;
        }
        public static PageLayout CurPageLayout = null;
        public static bool IsBackground;
    }
 
}
namespace ON.Ios
{
    // The UIApplicationDelegate for the application. This class is responsible for launching the
    // User Interface of the application, as well as listening (and optionally responding) to application events from iOS.FinishLaunching
    [Register ("AppDelegate")]
    public class AppDelegate : BaseDelegate // BaseApplicationDelegateForHdlOn
    {
        public override UIWindow Window{
            get;
            set;
        }
 
        public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
        {
            Console.WriteLine ("FinishedLaunching");
            base.FinishedLaunching (application, launchOptions);
 
            SharedMethod.SharedMethod.sharedApp = application;
 
            Window = new UIWindow (UIScreen.MainScreen.Bounds);
            var Root = new UINavigationController (new ViewController ()) { NavigationBarHidden = true };
            Window.RootViewController = Root;
            Window.MakeKeyAndVisible ();
            application.StatusBarStyle = UIStatusBarStyle.DarkContent;
            Shared.Application.Skin = "Phone2";
            SkinStyle.Current.ChangeColor ();
 
            return true;
        }
 
 
        public override void OnResignActivation (UIApplication application)
        {
            Console.WriteLine ("OnResignActivation");
            Shared.BusSocket.Stop ();
        }
 
        public override void DidEnterBackground (UIApplication application)
        {
            SharedMethod.SharedMethod.IsBackground = true;
            Console.WriteLine ("DidEnterBackground");
        }
 
        public override void WillEnterForeground (UIApplication application)
        {
            SharedMethod.SharedMethod.IsBackground = false;
        }
 
        public override void WillTerminate (UIApplication application)
        {
            Console.WriteLine ("WillTerminate");
        }
 
        public override void OnActivated (UIApplication application)
        {
            Console.WriteLine ("OnActivated");
            base.OnActivated (application);
 
            //有些系统版本这里启动比视图控制器快
            if (!Shared.SimpleControl.MainPage.Showed) {
                System.Threading.Tasks.Task.Run (() => {
                    while (true) {
                        System.Threading.Thread.Sleep (10);
                        if (Shared.SimpleControl.MainPage.Showed) {
                            break;
                        }
                    }
                    Shared.Application.RunOnMainThread (() => {
                        Shared.BusSocket.Start (6000);
                    });
                });
                return;
            }
            Shared.BusSocket.Start (6000);
        }
    }
}