protected sealed override async void OnCreate(Bundle?savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Platform.Init(this, savedInstanceState);

            var themeProvider = GetThemeProvider();

            var displayMetrics = Resources?.DisplayMetrics ?? throw new NullReferenceException();


            var fontProvider = new AndroidFontProvider(displayMetrics);

            var uiProvider = new AndroidUiProvider(this);

            var windowManager = WindowManager ?? throw new NullReferenceException(
                                          "WindowManager cannot be null");

            var viewState = new AndroidViewState(displayMetrics, themeProvider);

            var resolver      = GetDependencyContainer();
            var imageProvider = GetImageProvider(displayMetrics);

            var renderKit = new AndroidRenderKit(new BasePerspective(), viewState,
                                                 fontProvider, windowManager, uiProvider, themeProvider,
                                                 displayMetrics, resolver, imageProvider);

            _view = await GetMainViewAsync(renderKit, uiProvider);

            var prov = new AndroidView(_view, Application.Context, renderKit, uiProvider);

            SetContentView(prov);
        }
示例#2
0
        private static AndroidRenderKit BuildRenderKit(Context context,
                                                       IWindowManager windowManager,
                                                       IUiProvider uiProvider,
                                                       IThemeProvider themeProvider,
                                                       IResolver resolver)
        {
            var displayMetrics = context.Resources?.DisplayMetrics ?? throw new NullReferenceException();


            var viewState = new AndroidViewState(displayMetrics, themeProvider);

            var fontProvider = new AndroidFontProvider(displayMetrics);

            return(new AndroidRenderKit(new BasePerspective(), viewState,
                                        fontProvider, windowManager, uiProvider, themeProvider, displayMetrics,
                                        resolver, new AndroidImageProvider(displayMetrics)));
        }