Beispiel #1
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();
        }
 static PlatformExtensions()
 {
     IsApiGreaterThan10          = Build.VERSION.SdkInt > BuildVersionCodes.GingerbreadMr1;
     IsApiLessThanOrEqualTo10    = !IsApiGreaterThan10;
     IsApiGreaterThanOrEqualTo21 = Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop;
     IsApiGreaterThanOrEqualTo14 = Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich;
     IsApiGreaterThanOrEqualTo17 = Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1;
     FragmentConstant            = DataConstant.Create(() => FragmentConstant, false);
     _menuInflaterFactory        = (context, dataContext) => new BindableMenuInflater(context);
     _layoutInflaterFactory      = (context, dataContext, factory, inflater) =>
     {
         if (factory == null && !ServiceProvider.TryGet(out factory))
         {
             factory = new ViewFactory();
         }
         if (inflater == null)
         {
             return(new BindableLayoutInflater(factory, context));
         }
         return(new BindableLayoutInflater(factory, inflater, context));
     };
     ContentViewManagerField = new ContentViewManager();
     ContentViewManagerField.Add(new ViewContentViewManager());
     _mvvmActivityMediatorFactory = MvvmActivityMediatorFactoryMethod;
     _getContentViewDelegete      = GetContentViewInternal;
     _setContentViewDelegete      = ContentViewManagerField.SetContent;
     _isFragment                       = o => false;
     _isActionBar                      = _isFragment;
     _activityRef                      = Empty.WeakReference;
     WeakReferences                    = new ConcurrentDictionary <int, WeakReference>(2, Empty.Array <KeyValuePair <int, WeakReference> >(), EqualityComparer <int> .Default);
     ViewToContextConstructor          = new ConcurrentDictionary <Type, Func <object[], object> >();
     ViewToContextWithAttrsConstructor = new ConcurrentDictionary <Type, Func <object[], object> >();
     ViewContextArgs                   = new[] { typeof(Context) };
     ViewContextWithAttrsArgs          = new[] { typeof(Context), typeof(IAttributeSet) };
     CurrentActivityLocker             = new object();
     _mvvmFragmentMediatorFactory      = MvvmFragmentMediatorFactoryMethod;
     // ReSharper disable once ObjectCreationAsStatement
     new WeakReferenceCollector();
 }
Beispiel #3
0
 public static void AddContentViewManager([NotNull] IContentViewManager contentViewManager)
 {
     ContentViewManagerField.Add(contentViewManager);
 }