Esempio n. 1
0
        private void selectItem(int position)
        {
            // update the main content by replacing fragments
            var fragment = DisplayFragment.NewInstance();

            if (position == 0)
            {
                fragment = DisplayFragment.NewInstance();
            }
            else if (position == 1)
            {
                fragment = SettingsFragment.NewInstance();
            }
            else if (position == 2)
            {
                fragment = HelpFragment.NewInstance();
            }

            var fragmentManager = this.FragmentManager;
            var ft = fragmentManager.BeginTransaction();

            ft.Replace(Resource.Id.content_frame, fragment);
            ft.Commit();

            // update selected item title, then close the drawer
            mDrawerLayout.CloseDrawer(mDrawerList);
        }
Esempio n. 2
0
        private void ListItemClicked(int position)
        {
            try
            {
                _editItemVisible    = false;
                _requestItemVisible = false;
                //this way we don't load twice, but you might want to modify this a bit.
                if (position == _oldPosition) //perhaps allow loading of homepage again???
                {
                    return;
                }

                _oldPosition = position;
                Android.Support.V4.App.Fragment interfaceFragment = null;
                switch (position)
                {
                case 0:     //Home page
                    //interfaceFragment = HomePageFragment.NewInstance();
                    interfaceFragment = HomePageFragment.NewInstance();
                    _viewTitle        = "Auto Folio";
                    break;

                case 1:     //My Profile
                    interfaceFragment = UserProfileFragment.NewInstance();
                    //interfaceFragment = TestLayoutFragment.NewInstance();
                    interfaceFragment.Arguments = _dataBundle;
                    _viewTitle       = "My Profile";
                    _editItemVisible = true;
                    break;

                case 2:     //MY Inventory
                    interfaceFragment           = UserInventoryFragment.NewInstance();
                    interfaceFragment.Arguments = _dataBundle;
                    _viewTitle = "My Inventory";
                    break;

                case 3:     //MY Requests
                    interfaceFragment           = UserRequestsFragment.NewInstance();
                    interfaceFragment.Arguments = _dataBundle;
                    _viewTitle          = "Requests";
                    _requestItemVisible = true;
                    break;

                case 4:     //Settings
                    interfaceFragment           = UserSettingsFragment.NewInstance();
                    interfaceFragment.Arguments = _dataBundle;
                    _viewTitle = "Settings";
                    break;

                case 5:     //HELP
                    interfaceFragment = HelpFragment.NewInstance();
                    _viewTitle        = "Help";
                    break;

                case 6:     //Sign out
                    //confirm user action
                    SignOutUser();
                    break;
                }

                Toolbar.Title = _viewTitle;
                if (_editProfileMenuItem != null)
                {
                    _editProfileMenuItem.SetVisible(_editItemVisible);
                }

                if (_addRequestItem != null)
                {
                    _addRequestItem.SetVisible(_requestItemVisible);
                }
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, interfaceFragment)
                .Commit();
            }
            catch (Exception ex)
            {
                var message = string.Format("Error loading home details {0} {1}", ex.Message, ex.StackTrace);
                Console.WriteLine(message);
                MetricsManager.TrackEvent(message);
                Toast.MakeText(this, "Vehicle not details lodaded successfully, please try again " + ex.Message,
                               ToastLength.Short);
                ListItemClicked(0); //reset to homepage
            }
        }