Exemple #1
0
        protected override void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    _shellContext.Shell.PropertyChanged -= OnShellPropertyChanged;

                    if (_flyoutHeader != null)
                    {
                        _flyoutHeader.MeasureInvalidated += OnFlyoutHeaderMeasureInvalidated;
                    }

                    _headerView.Dispose();
                    _rootView.Dispose();
                    _layoutManager?.Dispose();
                    _defaultBackgroundColor?.Dispose();
                    _bgImage?.Dispose();
                }

                _flyoutHeader           = null;
                _defaultBackgroundColor = null;
                _bgImage       = null;
                _rootView      = null;
                _headerView    = null;
                _shellContext  = null;
                _layoutManager = null;
                _disposed      = true;
            }
            base.Dispose(disposing);
        }
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                _shellContext.Shell.PropertyChanged -= OnShellPropertyChanged;

                if (_flyoutHeader != null)
                {
                    _flyoutHeader.MeasureInvalidated -= OnFlyoutHeaderMeasureInvalidated;
                }

                if (_appBar != null)
                {
                    _appBar.RemoveOnOffsetChangedListener(this);
                    _appBar.RemoveView(_headerView);
                }

                if (_rootView != null && _footerView?.NativeView != null)
                {
                    _rootView.RemoveView(_footerView.NativeView);
                }

                if (_recycler != null)
                {
                    _recycler.SetLayoutManager(null);
                    _recycler.SetAdapter(null);
                    _recycler.Dispose();
                }

                _adapter?.Dispose();
                _headerView.Dispose();
                _footerView?.TearDown();
                _rootView.Dispose();
                _layoutManager?.Dispose();
                _defaultBackgroundColor?.Dispose();
                _bgImage?.Dispose();

                _flyoutHeader           = null;
                _rootView               = null;
                _headerView             = null;
                _shellContext           = null;
                _appBar                 = null;
                _recycler               = null;
                _adapter                = null;
                _defaultBackgroundColor = null;
                _layoutManager          = null;
                _bgImage                = null;
                _footerView             = null;
            }

            base.Dispose(disposing);
        }
Exemple #3
0
 public RecyclerViewContainer(Context context, ShellFlyoutRecyclerAdapter shellFlyoutRecyclerAdapter) : base(context)
 {
     _shellFlyoutRecyclerAdapter = shellFlyoutRecyclerAdapter;
     SetClipToPadding(false);
     SetLayoutManager(_layoutManager = new ScrollLayoutManager(context, (int)Orientation.Vertical, false));
     SetLayoutManager(new LinearLayoutManager(context, (int)Orientation.Vertical, false));
     SetAdapter(_shellFlyoutRecyclerAdapter);
 }
Exemple #4
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;
            if (disposing)
            {
                SetLayoutManager(null);
                SetAdapter(null);
                _shellFlyoutRecyclerAdapter?.Dispose();
                _layoutManager?.Dispose();
                _shellFlyoutRecyclerAdapter = null;
                _layoutManager = null;
            }

            base.Dispose(disposing);
        }
Exemple #5
0
        protected virtual void LoadView(IShellContext shellContext)
        {
            Profile.FrameBegin();

            var context = shellContext.AndroidContext;

            // Android designer can't load fragments or resources from layouts
            if (context.IsDesignerContext())
            {
                _rootView = new FrameLayout(context);
                return;
            }

            var coordinator = LayoutInflater.FromContext(context).Inflate(Resource.Layout.FlyoutContent, null);

            Profile.FramePartition("Find Recycler");
            var recycler = coordinator.FindViewById <RecyclerView>(Resource.Id.flyoutcontent_recycler);

            Profile.FramePartition("Find AppBar");
            var appBar = coordinator.FindViewById <AppBarLayout>(Resource.Id.flyoutcontent_appbar);

            _rootView = coordinator as ViewGroup;

            Profile.FramePartition("Add Listener");
            appBar.AddOnOffsetChangedListener(this);

            Profile.FramePartition("Add HeaderView");
            _actionBarHeight = (int)context.ToPixels(56);

            _flyoutHeader = ((IShellController)shellContext.Shell).FlyoutHeader;
            if (_flyoutHeader != null)
            {
                _flyoutHeader.MeasureInvalidated += OnFlyoutHeaderMeasureInvalidated;
            }

            _headerView = new HeaderContainer(context, _flyoutHeader)
            {
                MatchWidth = true
            };
            _headerView.SetMinimumHeight(_actionBarHeight);
            _headerView.LayoutParameters = new AppBarLayout.LayoutParams(LP.MatchParent, LP.WrapContent)
            {
                ScrollFlags = AppBarLayout.LayoutParams.ScrollFlagScroll
            };
            appBar.AddView(_headerView);

            Profile.FramePartition("Recycler.SetAdapter");
            var adapter = new ShellFlyoutRecyclerAdapter(shellContext, OnElementSelected);

            recycler.SetClipToPadding(false);
            recycler.SetLayoutManager(_layoutManager = new ScrollLayoutManager(context, (int)Orientation.Vertical, false));
            recycler.SetAdapter(adapter);

            Profile.FramePartition("Initialize BgImage");
            var metrics = context.Resources.DisplayMetrics;
            var width   = Math.Min(metrics.WidthPixels, metrics.HeightPixels);

            using (TypedValue tv = new TypedValue())
            {
                if (context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ActionBarSize, tv, true))
                {
                    _actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, metrics);
                }
            }

            width -= _actionBarHeight;

            coordinator.LayoutParameters = new LP(width, LP.MatchParent);

            _bgImage = new ImageView(context)
            {
                LayoutParameters = new LP(coordinator.LayoutParameters)
            };

            Profile.FramePartition("UpdateFlyoutHeaderBehavior");
            UpdateFlyoutHeaderBehavior();
            _shellContext.Shell.PropertyChanged += OnShellPropertyChanged;

            Profile.FramePartition("UpdateFlyoutBackground");
            UpdateFlyoutBackground();

            Profile.FrameEnd();

            Profile.FramePartition(nameof(UpdateVerticalScrollMode));
            UpdateVerticalScrollMode();
            Profile.FrameEnd();
        }