Exemple #1
0
        public void DisplayView(MainEventHandlers.ViewsEnum position)
        {
            string title = GetString(Resource.String.AppName);
            Android.Support.V4.App.Fragment fragment;

            if (!app.ActivityStarted)
            {
                selectedView = position;
                return;
            }

            if (savedInstanceState)
            {
                return;
            }

            if (!IsTabletLandscapeLayout)
            {
                switch (position)
                {
                    case MainEventHandlers.ViewsEnum.Profiles:
                        fragment = profilesFragment;
                        title = GetString(Resource.String.ProfileTitle);
                        break;
                    case MainEventHandlers.ViewsEnum.Bouquets:
                        fragment = bouquetsFragment;
                        title = GetString(Resource.String.BouquetsTitle);
                        break;
                    case MainEventHandlers.ViewsEnum.Services:
                        fragment = servicesFragment;
                        title = GetString(Resource.String.ServicesTitle);
                        break;
                    case MainEventHandlers.ViewsEnum.Signal:
                        fragment = signalFragment;
                        title = GetString(Resource.String.SignalTitle);
                        break;
                    default:
                        fragment = profilesFragment;
                        title = GetString(Resource.String.ProfileTitle);
                        break;
                }
                selectedView = position;

                if (savedInstanceState)
                    return;
                SupportFragmentManager.BeginTransaction().Replace(Resource.Id.container_body, fragment).CommitAllowingStateLoss();
                SupportFragmentManager.ExecutePendingTransactions();
                drawerFragment.Adapter.ClearSelections();
                drawerFragment.Adapter.ToggleSelection((int)position);
                SupportActionBar.Title = title;
            }
            else
            {
                if (savedInstanceState)
                    return;   
                SupportFragmentManager.BeginTransaction().Replace(Resource.Id.profiles_layout, profilesFragment).CommitAllowingStateLoss();
                SupportFragmentManager.BeginTransaction().Replace(Resource.Id.bouquets_layout, bouquetsFragment).CommitAllowingStateLoss();
                SupportFragmentManager.BeginTransaction().Replace(Resource.Id.services_layout, servicesFragment).CommitAllowingStateLoss();
                SupportFragmentManager.BeginTransaction().Replace(Resource.Id.signal_layout, signalFragment).CommitAllowingStateLoss();
                SupportFragmentManager.ExecutePendingTransactions();
                SupportActionBar.Title = title;

            }
        }
Exemple #2
0
        protected override void OnStart()
        {
            base.OnStart();
            app.ActivityStarted = true;

            if (eventHandlers == null)
            {
                eventHandlers = new MainEventHandlers(this);
                eventHandlers.DisplayView = this.DisplayView;
                eventHandlers.SetMenuVisibility = () => this.SetMenuVisibility();
                profilesFragment.ListItemClicked += eventHandlers.ProfileSelectedHandler;
                bouquetsFragment.ListItemClicked += eventHandlers.BouquetSelectedHandler;
                servicesFragment.ListItemClicked += eventHandlers.ServiceSelectedHandler;
                servicesFragment.ListItemLongClicked += eventHandlers.ServiceLongClickedHandler;
                ConnectionManager.GetInstance().PropertyChanged -= eventHandlers.ConnectionManager_PropertyChanged;
                ConnectionManager.GetInstance().PropertyChanged += eventHandlers.ConnectionManager_PropertyChanged;
                ConnectionManager.GetInstance().ExceptionRaised -= eventHandlers.ConnectionManager_ExceptionRaised;
                ConnectionManager.GetInstance().ExceptionRaised += eventHandlers.ConnectionManager_ExceptionRaised;
            }

            if (streamManager == null)
                streamManager = new StreamManager(this);

            Tapjoy.Tapjoy.OnActivityStart(this);

            if (!ConnectionManager.Connected)
                DisplayView(MainEventHandlers.ViewsEnum.Profiles);
            else
                DisplayView(selectedView);
            if (ConnectionManager.Connected)
                ConnectionManager.CurrentServiceMonitor.Start();

            if (ConnectionManager.ConnectionStatus == ConnectionManager.ConnectionStatusEnum.Connecting)
                eventHandlers.ShowProgressDialog();
        }