protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetTitle(Resource.String.attach);

            SetContentView(Resource.Layout.content_frame);
            SupportFragmentManager
            .BeginTransaction()
            .Replace(Resource.Id.content_frame, new SampleListFragment())
            .Commit();

            menu = new SlidingMenu(this)
            {
                TouchModeAbove         = SlidingMenu.TOUCHMODE_FULLSCREEN,
                ShadowWidthRes         = Resource.Dimension.shadow_width,
                ShadowDrawableResource = Resource.Drawable.shadow,
                BehindWidthRes         = Resource.Dimension.slidingmenu_offset,
                FadeDegree             = 0.35f
            };
            menu.AttachToActivity(this, SlidingMenu.SLIDING_CONTENT);
            menu.SetMenu(Resource.Layout.menu_frame);
            SupportFragmentManager
            .BeginTransaction()
            .Replace(Resource.Id.menu_frame, new SampleListFragment())
            .Commit();
        }
        public void OnPostCreate(Bundle savedInstanceState)
        {
            if (null == _viewBehind && null == _viewAbove)
            {
                throw new InvalidOperationException("Both SetBehindContentView must be called " +
                                                    "in OnCreate in addition to SetContentView.");
            }

            _onPostCreateCalled = true;

            _slidingMenu.AttachToActivity(_activity,
                                          _enableSlide ? SlideStyle.Window : SlideStyle.Content);

            bool open, secondary;

            if (null != savedInstanceState)
            {
                open      = savedInstanceState.GetBoolean("SlidingActivityHelper.open");
                secondary = savedInstanceState.GetBoolean("SlidingActivityHelper.secondary");
            }
            else
            {
                open      = false;
                secondary = false;
            }

            new Handler().Post(() =>
            {
                if (open)
                {
                    if (secondary)
                    {
                        _slidingMenu.ShowSecondaryMenu(false);
                    }
                    else
                    {
                        _slidingMenu.ShowMenu(false);
                    }
                }
                else
                {
                    _slidingMenu.ShowContent(false);
                }
            });
        }
        /// <summary>
        /// Further SlidingMenu initialization. Should be called within the activitiy's onPostCreate()
        /// </summary>
        /// <param name="savedInstanceState"> the saved instance state (unused) </param>
        public void OnPostCreate(Bundle savedInstanceState)
        {
            if (mViewBehind == null || mViewAbove == null)
            {
                throw new IllegalStateException("Both setBehindContentView must be called " + "in onCreate in addition to setContentView.");
            }

            mOnPostCreateCalled = true;

            mSlidingMenu.AttachToActivity(mActivity, mEnableSlide ? SlidingMenu.SLIDING_WINDOW : SlidingMenu.SLIDING_CONTENT);

            bool open;
            bool secondary;

            if (savedInstanceState != null)
            {
                open      = savedInstanceState.GetBoolean("SlidingActivityHelper.open");
                secondary = savedInstanceState.GetBoolean("SlidingActivityHelper.secondary");
            }
            else
            {
                open      = false;
                secondary = false;
            }
            (new Handler()).Post(() =>
            {
                if (open)
                {
                    if (secondary)
                    {
                        mSlidingMenu.ShowSecondaryMenu(false);
                    }
                    else
                    {
                        mSlidingMenu.ShowMenu(false);
                    }
                }
                else
                {
                    mSlidingMenu.ShowContent(false);
                }
            });
        }
Esempio n. 4
0
        public override void SetContentView(int layoutResId)
        {
            base.SetContentView(layoutResId);

            LegacyBar = FindViewById <LegacyBar.Library.Bar.LegacyBar>(Resource.Id.ActionBar);

            if (LegacyBar != null)
            {
                LegacyBar.Title = Title;
                LegacyBar.Theme = LegacyBarTheme.HoloBlack;

                LegacyBar.SetHomeAction(new ActionLegacyBarAction(this,
                                                                  () => _slidingMenu.Toggle(true),
                                                                  Resource.Drawable.Menu));

                if (RefreshCommand != null)
                {
                    LegacyBar.AddAction(new ActionLegacyBarAction(this, () => RefreshCommand.Execute(null), Resource.Drawable.Refresh));
                }

                _slidingMenu = new SlidingMenu(this)
                {
                    Mode                       = MenuMode.Left,
                    TouchModeAbove             = DisableMenuSwipe ? TouchMode.None : TouchMode.Fullscreen,
                    BehindOffset               = 50,
                    BehindWidth                = 400,
                    ShadowWidth                = 20,
                    ShadowDrawableRes          = Resource.Drawable.SlidingMenuShadow,
                    SecondaryShadowDrawableRes = Resource.Drawable.SlidingMenuShadowRight
                };

                _slidingMenu.SetBackgroundColor(Color.Black);
                _slidingMenu.AttachToActivity(this, SlideStyle.Content);
                _slidingMenu.SetMenu(Resource.Layout.MenuFrame);

                var menuFragment = new MenuFragment();
                menuFragment.ViewModel = new MenuViewModel(((ViewModelBase)ViewModel).Messenger);

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.MenuFrame, menuFragment).Commit();
            }
        }
Esempio n. 5
0
        protected override void OnViewModelSet()
        {
            //this.Parent.RequestWindowFeature (WindowFeatures.NoTitle);

            //RequestWindowFeature (WindowFeatures.NoTitle);

            homeViewModel = (HomeViewModel)ViewModel;

            SetContentView(Resource.Layout.Content_Frame);

            MenuId = Resource.Menu.HomeMenu;


            LegacyBar = FindViewById <LegacyBar.Library.Bar.LegacyBar>(Resource.Id.actionbar);

            //LegacyBar.SetHomeLogo(Resource.Drawable.jabbr_home_icon);
            AddHomeAction(() => {
                slidingMenu.Toggle();
            }, Resource.Drawable.jabbr_home_icon);

            LegacyBar.Click += (sender, e) => {
                slidingMenu.Toggle();
            };
            LegacyBar.Title = "JabbR";



            slidingMenu = new SlidingMenu(this)
            {
                Mode                       = MenuMode.LeftRight,
                TouchModeAbove             = TouchMode.Fullscreen,
                BehindOffset               = 80,
                ShadowWidth                = 20,
                ShadowDrawableRes          = Resource.Drawable.SlidingMenuShadow,
                SecondaryShadowDrawableRes = Resource.Drawable.SlidingMenuShadowRight
            };

            slidingMenu.AttachToActivity(this, SlideStyle.Content);
            slidingMenu.SetMenu(Resource.Layout.Menu_Frame);
            //slidingMenu.ShadowDrawableRes = Resource.Drawable.SlidingMenuShadow;

            menuFragment           = new MenuFragment();
            menuFragment.ViewModel = ViewModel;

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.menu_frame, menuFragment).Commit();

            slidingMenu.SetSecondaryMenu(Resource.Layout.UserList_Frame);
            //slidingMenu.SecondaryShadowDrawableRes = Resource.Drawable.SlidingMenuShadowRight;

            emptyFragment           = new EmptyFragment();
            emptyFragment.ViewModel = this.ViewModel;

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, emptyFragment).Commit();


            //TODO: Put some kind of default view in the chat fragment space

            homeViewModel.PropertyChanged += (sender, e) => {
                Console.WriteLine("PropertyChanged: " + e.PropertyName);

                if (e.PropertyName == "CurrentRoom")
                {
                    if (homeViewModel.CurrentRoom == null)
                    {
                        if (emptyFragment == null)
                        {
                            emptyFragment = new EmptyFragment();
                        }

                        chatFragment = null;

                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.content_frame, emptyFragment).Commit();

                        LegacyBar.Title = "JabbR";

                        showActions = false;
                        ToggleActions();

                        userListFragment.ViewModel = null;

                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.userlist_frame, userListFragment).Commit();
                        return;
                    }

                    showActions = true;


                    if (chatFragment == null)
                    {
                        chatFragment           = new ChatFragment();
                        chatFragment.ViewModel = homeViewModel.CurrentRoom;

                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.content_frame, chatFragment).Commit();
                    }
                    else
                    {
                        chatFragment.ViewModel = homeViewModel.CurrentRoom;
                    }

                    if (userListFragment == null)
                    {
                        userListFragment           = new UserListFragment();
                        userListFragment.ViewModel = homeViewModel.CurrentRoom;

                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.userlist_frame, userListFragment).Commit();
                    }
                    else
                    {
                        userListFragment.ViewModel = homeViewModel.CurrentRoom;
                    }


                    ToggleActions();

                    slidingMenu.Toggle();

                    this.RunOnUiThread(() => LegacyBar.Title = homeViewModel.CurrentRoom.Room.Name);
                }
            };

            messenger = Mvx.Resolve <IMvxMessenger> ();
            _mvxMsgTokUserSelected = messenger.SubscribeOnMainThread <UserSelectedMessage> (msg => {
                chatFragment.AppendText("@" + msg.User.Name);

                slidingMenu.ShowContent(true);
            });
        }