コード例 #1
0
ファイル: MainActivity.cs プロジェクト: fardage/Fernweh-App
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions,
                                                        [GeneratedEnum] Permission[] grantResults)
        {
            Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;
            Context           = this.ApplicationContext;

            base.OnCreate(savedInstanceState);
            Platform.Init(this, savedInstanceState);
            Forms.Init(this, savedInstanceState);
            AssetManager assets = this.Assets;

#if DEBUG
            if (Intent.Extras != null)
            {
                foreach (var key in Intent.Extras.KeySet())
                {
                    if (key != null)
                    {
                        var value = Intent.Extras.GetString(key);
                        Log.Debug(TAG, "Key: {0} Value: {1}", key, value);
                    }
                }
            }
#endif
            IsPlayServicesAvailable();
            CreateNotificationChannel();

            FirebaseMessaging.Instance.SubscribeToTopic(CHANNEL_ID);
            FirebaseMessaging.Instance.SubscribeToTopic(UPDATE_CHANNEL_NAME);

            LoadApplication(new App());
        }
コード例 #3
0
ファイル: MainActivity.cs プロジェクト: fardage/Fernweh-App
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            Forms.SetFlags("SwipeView_Experimental");

            Popup.Init(this);
            Platform.Init(this, savedInstanceState);
            Forms.Init(this, savedInstanceState);

            if (DeviceInfo.DeviceType == DeviceType.Physical)
            {
                AppCenter.Start(Credentials.ApiKeyAppCenter,
                                typeof(Analytics), typeof(Crashes));
            }

            var width   = Resources.DisplayMetrics.WidthPixels;
            var height  = Resources.DisplayMetrics.HeightPixels;
            var density = Resources.DisplayMetrics.Density;

            App.ScreenWidth  = (width - 0.5f) / density;
            App.ScreenHeight = (height - 0.5f) / density;

            LoadApplication(new App());
        }
コード例 #4
0
ファイル: App.cs プロジェクト: ziyuejun/SteamTools
        public sealed override void OnCreate()
        {
            base.OnCreate();

            if (EnableThreadUncaughtExceptionHandler)
            {
                ThreadUncaughtExceptionHandler.Initialize();
            }

            CrossCurrentActivity.Current.Init(this);

            var options = AppSettings;

            #region Visual Studio App Center

            if (options.AppSecretVisualStudioAppCenter != null)
            {
                // Visual Studio App Center
                // 将移动开发人员常用的多种服务整合到一个集成的产品中。
                // 您可以构建,测试,分发和监控移动应用程序,还可以实施推送通知。
                // https://docs.microsoft.com/zh-cn/appcenter/sdk/getting-started/xamarin
                // https://visualstudio.microsoft.com/zh-hans/app-center
                AppCenter.Start(options.AppSecretVisualStudioAppCenter, typeof(Analytics), typeof(Crashes));
            }

            #endregion

            XEFileProvider.TemporaryLocation = FileProviderLocation.Internal;
            XEPlatform.Init(this); // 初始化 Xamarin.Essentials.Platform.Init

            var isMainProcess = IsMainProcess();

            DI.Init(ConfigureServices);

            void ConfigureServices(IServiceCollection services)
            {
                ConfigureRequiredServices(services, options);
                if (isMainProcess)
                {
                    ConfigureMainProcessServices(services, options);
                }
            }

            if (isMainProcess)
            {
                XEVersionTracking.Track();

                // 厂商ROM检测
                AndroidROM.Initialize();

                // Emoji表情
                EmojiCompatLibrary.Init(this);
            }

            OnCreated(options, isMainProcess);

#if DEBUG
            Log.Debug("Application", "OnCreate Complete.");
#endif
        }
コード例 #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            XamarinEssentialsPlatform.Init(this, savedInstanceState);
            Forms.Init(this, savedInstanceState);
            LoadApplication(new BlazorApp());
        }
コード例 #6
0
    #pragma warning restore 8618


    protected void Init(Bundle savedInstanceState, params string[] flags)
    {
        global::Xamarin.Forms.Forms.SetFlags(flags);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        FormsMaterial.Init(this, savedInstanceState);
        Platform.Init(this, savedInstanceState);

        Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState);
        Acr.UserDialogs.UserDialogs.Init(this);

        Instance = this;
    }
コード例 #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            Xamarin.Forms.Forms.SetFlags("Brush_Experimental", "Shapes_Experimental");
            Platform.Init(this, savedInstanceState);
            XamForms.Init(this, savedInstanceState);
            LoadApplication(new App());
        }
コード例 #8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            string here = $"{nameof(LoginActivity)}->{nameof(OnCreate)}";

            base.OnCreate(savedInstanceState);
            XPlatform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.Login);

            loginController.Startup();
            binding = new Login(this);
            binding.btnLogin.Click              += LoginClicked;
            binding.txtUsername.TextChanged     += (sender, args) => loginViewModel.Username = String.Concat(args.Text);
            binding.txtPassword.TextChanged     += (sender, args) => loginViewModel.Password = String.Concat(args.Text);
            binding.chkRememberMe.CheckedChange += (sender, args) => loginViewModel.RememberMe = args.IsChecked;
            loginViewModel.RememberMe            = Preferences.Get(nameof(LoginViewModel.RememberMe), default(bool), "login");

            logService.Info(here, $"{nameof(LoginViewModel.RememberMe)}: {loginViewModel.RememberMe}");
            if (loginViewModel.RememberMe) /*then*/ binding {
コード例 #9
0
ファイル: MainApplication.cs プロジェクト: zzqxztc/SteamTools
        public override void OnCreate()
        {
            base.OnCreate();

            VisualStudioAppCenterSDK.Init();

            XEFileProvider.TemporaryLocation = FileProviderLocation.Internal;
            XEPlatform.Init(this); // 初始化 Xamarin.Essentials.Platform.Init

            bool GetIsMainProcess()
            {
                // 注意:进程名可以自定义,默认是包名,如果自定义了主进程名,这里就有误,所以不要自定义主进程名!
                var name = this.GetCurrentProcessName();

                return(name == PackageName);
            }

            IsMainProcess = GetIsMainProcess();

            DILevel level = DILevel.Min;

            if (IsMainProcess)
            {
                level = DILevel.MainProcess;
            }
            Startup.Init(level);

            if (IsMainProcess)
            {
                XEVersionTracking.Track();
            }

#if DEBUG
            Log.Debug("Application", "OnCreate Complete.");
#endif
        }
コード例 #10
0
        protected override void OnResume()
        {
            base.OnResume();

            XamarinEssentialsPlatform.OnResume();
        }
コード例 #11
0
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
        {
            XamarinEssentialsPlatform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
コード例 #12
0
        //#if DEBUG
        //RefWatcher? _refWatcher;

        //void SetupLeakCanary()
        //{
        //    // “A small leak will sink a great ship.” - Benjamin Franklin
        //    if (LeakCanaryXamarin.IsInAnalyzerProcess(this))
        //    {
        //        // This process is dedicated to LeakCanary for heap analysis.
        //        // You should not init your app in this process.
        //        return;
        //    }
        //    _refWatcher = LeakCanaryXamarin.Install(this);
        //}
        //#endif

        public override void OnCreate()
        {
            base.OnCreate();
            //#if DEBUG
            //            //SetupLeakCanary();
            //#endif
            var stopwatch  = Stopwatch.StartNew();
            var startTrace = new StringBuilder();

            FileSystem2.InitFileSystem();

            stopwatch.Stop();
            startTrace.AppendFormatLine("init FileSystem {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            IApplication.InitLogDir();

            stopwatch.Stop();
            startTrace.AppendFormatLine("init NLog {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            Startup.InitGlobalExceptionHandler();

            stopwatch.Stop();
            startTrace.AppendFormatLine("init ExceptionHandler {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            VisualStudioAppCenterSDK.Init();

            stopwatch.Stop();
            startTrace.AppendFormatLine("init AppCenter {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            XEFileProvider.TemporaryLocation = FileProviderLocation.Internal;
            XEPlatform.Init(this); // 初始化 Xamarin.Essentials.Platform.Init

            XEPlatform.ActivityStateChanged += OnActivityStateChanged;

            stopwatch.Stop();
            startTrace.AppendFormatLine("init Essentials {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            bool GetIsMainProcess()
            {
                // 注意:进程名可以自定义,默认是包名,如果自定义了主进程名,这里就有误,所以不要自定义主进程名!
                var name = this.GetCurrentProcessName();

                return(name == PackageName);
            }

            IsMainProcess = GetIsMainProcess();

            stopwatch.Stop();
            startTrace.AppendFormatLine("init IsMainProcess {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            SettingsHost.Load();

            stopwatch.Stop();
            startTrace.AppendFormatLine("init SettingsHost {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            InitSettingSubscribe();

            stopwatch.Stop();
            startTrace.AppendFormatLine("init SettingSubscribe {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            var level = DILevel.Min;

            if (IsMainProcess)
            {
                level = DILevel.MainProcess;
            }
            Startup.Init(level);

            stopwatch.Stop();
            startTrace.AppendFormatLine("init Startup {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            if (IsMainProcess)
            {
                XEVersionTracking.Track();

                stopwatch.Stop();
                startTrace.AppendFormatLine("init VersionTracking {0}ms", stopwatch.ElapsedMilliseconds);
                stopwatch.Restart();

                if (XEVersionTracking.IsFirstLaunchForCurrentVersion)
                {
                    // 当前版本第一次启动时,清除存放升级包缓存文件夹的目录
                    IApplicationUpdateService.ClearAllPackCacheDir();

                    stopwatch.Stop();
                    startTrace.AppendFormatLine("init ClearAllPackCacheDir {0}ms", stopwatch.ElapsedMilliseconds);
                    stopwatch.Restart();
                }
            }
            UISettings.Language.Subscribe(x => R.ChangeLanguage(x));

            stopwatch.Stop();
            startTrace.AppendFormatLine("init Language.Subscribe {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            Startup.OnStartup(IsMainProcess);

            stopwatch.Stop();
            startTrace.AppendFormatLine("init OnStartup {0}ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            if (IsMainProcess)
            {
                var vmService = IViewModelManager.Instance;
                vmService.InitViewModels();

                stopwatch.Stop();
                startTrace.AppendFormatLine("init ViewModels {0}ms", stopwatch.ElapsedMilliseconds);
                stopwatch.Restart();

#if __XAMARIN_FORMS__
                Forms.Init(this, null);
                FormsMaterial.Init(this, null);
                ImageCircleRenderer.Init();

                stopwatch.Stop();
                startTrace.AppendFormatLine("init XF {0}ms", stopwatch.ElapsedMilliseconds);
                stopwatch.Restart();

                _Current = new(RealTheme);

                stopwatch.Stop();
                startTrace.AppendFormatLine("init XFApp {0}ms", stopwatch.ElapsedMilliseconds);
                stopwatch.Restart();
#endif
                vmService.MainWindow.Initialize();
            }

            stopwatch.Stop();
            StartupTrack = startTrace.ToString();
#if DEBUG
            Log.Warn("Application", $"OnCreate Complete({stopwatch.ElapsedMilliseconds}ms");
#endif
        }