Beispiel #1
0
        public AndroidView(IVisualElement view,
                           Context context,
                           AndroidRenderKit renderKit,
                           IUiProvider uiProvider)
            : base(context)
        {
            _loopHandler = new Handler(Looper.MainLooper);
            _measured    = Size.Empty;
            _targetRect  = ValueRectangle.Empty;
            _view        = view;
            _surrogates  = new AndroidSurrogateProvider(renderKit, uiProvider, this);

            RenderKit  = renderKit;
            _viewState = renderKit.ViewState;


            ZoomLevel = renderKit.DisplayMetrics.ScaledDensity;

            //System.Diagnostics.Debug.WriteLine("Built android view with display w/h: " +
            //                                   renderKit.DisplayMetrics.WidthPixels + ", " +
            //                                   renderKit.DisplayMetrics.HeightPixels + " dpi: " +
            //                                   renderKit.DisplayMetrics.ScaledDensity);


            _paintView = new AndroidPaintView(context, renderKit, view);
            AddView(_paintView);

            var inputHandler = new BaseInputHandler(RenderKit.RenderContext);

            _inputContext = new AndroidInputContext(this, context, inputHandler, _viewState);

            renderKit.Container.ResolveTo(this);
        }
        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);
        }
Beispiel #3
0
        public AndroidPaintView(Context?context,
                                AndroidRenderKit renderKit,
                                IVisualElement view)
            : base(context)
        {
            _renderContext  = renderKit.RenderContext;
            _measureContext = renderKit.MeasureContext;
            _targetRect     = ValueRectangle.Empty;
            _view           = view;

            _viewState = renderKit.RenderContext.ViewState ?? throw new NullReferenceException();
        }