protected override View OnCreateView(string name, IAttributeSet attrs)
        {
            if (Debug)
            {
                System.Diagnostics.Debug.WriteLine("{Tag} - ... OnCreateView 2 ... {name}", Tag, name);
            }

            View view = AndroidViewFactory?.CreateView(null, name, Context, attrs) ??
                        PhoneLayoutInflaterOnCreateView(name, attrs) ??
                        base.OnCreateView(name, attrs);

            return(_bindingVisitor.OnViewCreated(view, Context, attrs));
        }
Beispiel #2
0
        protected override View OnCreateView(string name, IAttributeSet attrs)
        {
            if (Debug)
            {
                MvxLog.Instance.Trace("{Tag} - ... OnCreateView 2 ... {name}", Tag, name);
            }

            View view = AndroidViewFactory?.CreateView(null, name, Context, attrs) ??
                        PhoneLayoutInflaterOnCreateView(name, attrs) ??
                        base.OnCreateView(name, attrs);

            return(_bindingVisitor.OnViewCreated(view, Context, attrs));
        }
        protected override View OnCreateView(string name, IAttributeSet attrs)
        {
            if (Debug)
            {
                Mvx.TaggedTrace(Tag, "... OnCreateView 2 ... {0}", name);
            }

            View view = AndroidViewFactory.CreateView(null, name, Context, attrs) ??
                        PhoneLayoutInflaterOnCreateView(name, attrs) ??
                        base.OnCreateView(name, attrs);

            return(_bindingVisitor.OnViewCreated(view, Context, attrs));
        }
Beispiel #4
0
        protected View CreateCustomViewInternal(View parent, View view, string name, Context viewContext,
                                                IAttributeSet attrs)
        {
            if (Debug)
            {
                MvxLog.Instance.Trace(Tag, "... CreateCustomViewInternal ... {0}", name);
            }

            if (view == null && name.IndexOf('.') > -1)
            {
                // Attempt to inflate with MvvmCross unless we're trying to inflate an internal views
                // since we don't resolve those.
                if (!name.StartsWith("com.android.internal."))
                {
                    view = AndroidViewFactory.CreateView(parent, name, viewContext, attrs);
                }

                if (view == null)
                {
                    if (_constructorArgs == null)
                    {
                        Class layoutInflaterClass = Class.FromType(typeof(LayoutInflater));
                        _constructorArgs            = layoutInflaterClass.GetDeclaredField("mConstructorArgs");
                        _constructorArgs.Accessible = true;
                    }

                    Object[] constructorArgsArr = (Object[])_constructorArgs.Get(this);
                    Object   lastContext        = constructorArgsArr[0];

                    // The LayoutInflater actually finds out the correct context to use. We just need to set
                    // it on the mConstructor for the internal method.
                    // Set the constructor args up for the createView, not sure why we can't pass these in.
                    constructorArgsArr[0] = viewContext;
                    _constructorArgs.Set(this, constructorArgsArr);
                    try
                    {
                        view = CreateView(name, null, attrs);
                    }
                    catch (ClassNotFoundException)
                    {
                    }
                    finally
                    {
                        constructorArgsArr[0] = lastContext;
                        _constructorArgs.Set(this, constructorArgsArr);
                    }
                }
            }
            return(view);
        }
Beispiel #5
0
        public View OnCreateView(string name, Context context, IAttributeSet attrs)
        {
            if (name == "fragment")
            {
                // MvvmCross does not inflate Fragments - instead it returns null and lets Android inflate them.
                return(null);
            }

            View view = AndroidViewFactory.CreateView(name, context, attrs);

            if (view != null)
            {
                Binder.BindView(view, context, attrs);
            }

            return(view);
        }
Beispiel #6
0
        protected override View?OnCreateView(string?name, IAttributeSet?attrs)
        {
            if (Debug)
            {
                MvxLogHost.GetLog <MvxLayoutInflater>()?.Log(LogLevel.Trace, "{Tag} - ... OnCreateView 2 ... {name}", Tag, name);
            }

            View?view = null;

            if (name != null && Context != null && attrs != null)
            {
                view = AndroidViewFactory?.CreateView(null, name, Context, attrs);
            }

            view ??= PhoneLayoutInflaterOnCreateView(name, attrs) ?? base.OnCreateView(name, attrs);

            return(_bindingVisitor.OnViewCreated(view, Context, attrs));
        }
Beispiel #7
0
        internal View?CreateCustomViewInternal(View?parent, View?view, string name, Context viewContext,
                                               IAttributeSet attrs)
        {
            if (Debug)
            {
                MvxLogHost.GetLog <MvxLayoutInflater>()?.Log(LogLevel.Trace, "{Tag} - ... CreateCustomViewInternal ... {name}", Tag, name);
            }

            if (view == null &&
                !string.IsNullOrWhiteSpace(name) &&
                name.IndexOf('.', StringComparison.InvariantCulture) > -1)
            {
                // Attempt to inflate with MvvmCross unless we're trying to inflate an internal views
                // since we don't resolve those.
                if (!name.StartsWith("com.android.internal.", StringComparison.InvariantCulture))
                {
                    view = AndroidViewFactory?.CreateView(parent, name, viewContext, attrs);
                }

                if (view == null)
                {
                    var(constructorArgsArr, lastContext) = GetConstructorArgs(viewContext);

                    try
                    {
                        view = CreateViewCompat(viewContext, name, attrs);
                    }
                    catch (ClassNotFoundException)
                    {
                    }
                    finally
                    {
                        RestoreConstructorArgs(constructorArgsArr, lastContext);
                    }
                }
            }

            return(view);
        }
Beispiel #8
0
        protected View CreateCustomViewInternal(View parent, View view, string name, Context viewContext,
                                                IAttributeSet attrs)
        {
            if (Debug)
            {
                MvxLog.Instance.Trace("{Tag} - ... CreateCustomViewInternal ... {name}", Tag, name);
            }

            if (view == null &&
                !string.IsNullOrWhiteSpace(name) &&
                name.IndexOf('.', StringComparison.InvariantCulture) > -1)
            {
                // Attempt to inflate with MvvmCross unless we're trying to inflate an internal views
                // since we don't resolve those.
                if (!name.StartsWith("com.android.internal.", StringComparison.InvariantCulture))
                {
                    view = AndroidViewFactory?.CreateView(parent, name, viewContext, attrs);
                }

                if (view == null)
                {
                    Object[] constructorArgsArr = null;
                    Object   lastContext        = null;

                    if (Build.VERSION.SdkInt <= BuildVersionCodes.P)
                    {
                        if (_constructorArgs == null)
                        {
                            Class layoutInflaterClass = Class.FromType(typeof(LayoutInflater));
                            _constructorArgs            = layoutInflaterClass.GetDeclaredField("mConstructorArgs");
                            _constructorArgs.Accessible = true;
                        }

                        constructorArgsArr = (Object[])_constructorArgs.Get(this);
                        lastContext        = constructorArgsArr[0];

                        // The LayoutInflater actually finds out the correct context to use. We just need to set
                        // it on the mConstructor for the internal method.
                        // Set the constructor args up for the createView, not sure why we can't pass these in.
                        constructorArgsArr[0] = viewContext;
                        _constructorArgs.Set(this, constructorArgsArr);
                    }

                    try
                    {
#if __ANDROID_29__
                        if (Build.VERSION.SdkInt > BuildVersionCodes.P)
                        {
                            view = CreateView(viewContext, name, null, attrs);
                        }
                        else
#endif
                        view = CreateView(name, null, attrs);
                    }
                    catch (ClassNotFoundException)
                    {
                    }
                    finally
                    {
                        if (Build.VERSION.SdkInt <= BuildVersionCodes.P)
                        {
                            constructorArgsArr[0] = lastContext;
                            _constructorArgs.Set(this, constructorArgsArr);
                        }
                    }
                }
            }
            return(view);
        }