public override bool Load(IModuleContext context)
        {
            var mediatorFactory = AndroidToolkitExtensions.MediatorFactory;

            AndroidToolkitExtensions.MediatorFactory = (o, dataContext, arg3) =>
            {
                return(AndroidToolkitExtensions.MvvmActivityMediatorDefaultFactory(o, dataContext, arg3) ?? mediatorFactory?.Invoke(o, dataContext, arg3));
            };
            AndroidToolkitExtensions.LayoutInflaterFactory = (c, dataContext, factory, inflater) =>
            {
                if (inflater == null)
                {
                    Tracer.Error("The bindable inflater cannot be created without the original inflater");
                    return(null);
                }
                LayoutInflaterFactoryWrapper.SetFactory(inflater, factory);
                return(inflater);
            };
            AndroidToolkitExtensions.MenuInflaterFactory = (c, baseMenuInflater, ctx) => new BindableMenuInflater(c)
            {
                NestedMenuInflater = baseMenuInflater
            };
            AndroidToolkitExtensions.GetContentView = AndroidToolkitExtensions.GetContentViewDefault;
            AndroidToolkitExtensions.AddContentViewManager(new ViewContentViewManager());

            BindNavigationService(context, context.IocContainer);
            BindViewFactory(context, context.IocContainer);

            return(base.Load(context));
        }
Beispiel #2
0
        static PlatformExtensions()
        {
            IsApiGreaterThan10          = Build.VERSION.SdkInt > BuildVersionCodes.GingerbreadMr1;
            IsApiLessThanOrEqualTo10    = !IsApiGreaterThan10;
            IsApiGreaterThanOrEqualTo14 = Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich;
            IsApiGreaterThanOrEqualTo17 = Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1;
            IsApiGreaterThanOrEqualTo19 = Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat;
            IsApiGreaterThanOrEqualTo21 = Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop;
            FragmentConstant            = DataConstant.Create <object>(typeof(PlatformExtensions), nameof(FragmentConstant), false);
            _menuInflaterFactory        = (context, dataContext) => new BindableMenuInflater(context);
            _layoutInflaterFactory      = (context, dataContext, factory, inflater) =>
            {
                if (inflater == null)
                {
                    Tracer.Error("The bindable inflater cannot be created without the original inflater");
                    return(null);
                }
                LayoutInflaterFactoryWrapper.SetFactory(inflater, factory);
                return(inflater);
            };
            ContentViewManagerField = new ContentViewManager();
            ContentViewManagerField.Add(new ViewContentViewManager());
            _mvvmActivityMediatorFactory = MvvmActivityMediatorFactoryMethod;
            _getContentViewDelegete      = GetContentViewInternal;
            _setContentViewDelegete      = ContentViewManagerField.SetContent;
            _isFragment                       = o => false;
            _isActionBar                      = _isFragment;
            _activityRef                      = Empty.WeakReference;
            ViewToContextConstructor          = new ConcurrentDictionary <Type, Func <object[], object> >();
            ViewToContextWithAttrsConstructor = new ConcurrentDictionary <Type, Func <object[], object> >();
            ObjectToDefaultJavaConstructor    = new ConcurrentDictionary <Type, bool>();
            ViewContextArgs                   = new[] { typeof(Context) };
            ViewContextWithAttrsArgs          = new[] { typeof(Context), typeof(IAttributeSet) };
            DefaultJavaConstructorArgs        = new[] { typeof(IntPtr), typeof(JniHandleOwnership) };
            WeakReferencesHolder              = new List <object>(1000);
            CurrentActivityLocker             = new object();
            _mvvmFragmentMediatorFactory      = MvvmFragmentMediatorFactoryMethod;
            EnableFastTextViewTextProperty    = true;

            // ReSharper disable once ObjectCreationAsStatement
            new WeakReferenceCollector();
        }