Exemplo n.º 1
0
        void LoadFragment(int id)
        {
            Android.Support.V4.App.Fragment fragment = null;
            switch (id)
            {
            case Resource.Id.menu_chat:
            case Resource.Id.menu_search:
            case Resource.Id.menu_groups:
                fragment = PlaceholderFragment.NewInstance();
                break;

            case Resource.Id.menu_posts:
                fragment = PostsFragment.NewInstance();
                break;

            case Resource.Id.menu_profile:
                fragment = UserSettingsFragment.NewInstance();
                break;
            }
            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.FrameContent, fragment)
            .Commit();
        }
Exemplo 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
            }
        }