Esempio n. 1
0
        private void SetUpDrawerContent(NavigationView navigationView)
        {
            navigationView.BringToFront();
            LogInModule lg = new LogInModule();

            navigationView.NavigationItemSelected += (object sender, NavigationView.NavigationItemSelectedEventArgs e) =>
            {
                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_home:
                    ShowFragment(mHome);
                    mDrawerLayout.CloseDrawers();
                    break;

                case Resource.Id.nav_map:
                    ShowFragment(mapWithLabel);
                    mDrawerLayout.CloseDrawers();
                    break;

                case Resource.Id.nav_logOut:
                    lg.setFalseRemeberMe();                                 //set RememberMe to false - autoLogin to NoAutoLogin
                    Intent intent = new Intent(this, typeof(MainActivity)); // i tutaj trzeba dodać że jak się wylogowuje to wpisuje w plik LogInData.xml false wtedy będzie sie mogło wrzucić okno do logowania
                    this.StartActivity(intent);
                    this.Finish();
                    break;

                case Resource.Id.nav_set:
                    ShowFragment(mLocationMap);
                    mDrawerLayout.CloseDrawers();
                    break;

                default:
                    mDrawerLayout.CloseDrawers();
                    break;
                }
                e.MenuItem.SetChecked(true);
            };
        }
        protected override void OnCreate(Bundle b)
        {
            base.OnCreate(b);
            CrashManager.Register(this, Constants.KEY_HOCKEY);
            try
            {
                SetContentView(Resource.Layout.layout_home);

                Inject();


                int intentTab = Intent.GetIntExtra(Constants.INTENT_HOME_TAB, 0);
                if (intentTab > 0)
                {
                    SetCurrentTab(intentTab);
                }

                bnMain.NavigationItemSelected +=
                    delegate(object sender, BottomNavigationView.NavigationItemSelectedEventArgs e)
                {
                    e.Handled = true;
                    SetCurrentTab(e.Item.Order);
                };

                ViewHelper.DisableShiftMode(bnMain);

                ViewPagerAdapter vpAdapter = new ViewPagerAdapter(SupportFragmentManager);
                vpAdapter.AddFragment(new ControlFragment());
                vpAdapter.AddFragment(new RemoteFragment());
                vpAdapter.AddFragment(new ExtraFragment());
                vpAdapter.AddFragment(new AppSettingsFragment());
                vpMain.Adapter            = vpAdapter;
                vpMain.OffscreenPageLimit = 3;


                SetSupportActionBar(tbMain);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);

                abDrawerToggle = new ActionBarDrawerToggle(this, dlMain, tbMain, Resource.String.app_name,
                                                           Resource.String.app_name)
                {
                    DrawerIndicatorEnabled = true
                };

                dlMain.AddDrawerListener(abDrawerToggle);
                abDrawerToggle.SyncState();

                Window.AddFlags(WindowManagerFlags.TranslucentStatus);
                Window.ClearFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
                Window.SetStatusBarColor(Color.Transparent);


                smDrawerDevices = nvDrawer.Menu.AddSubMenu(0, 0, 0, "Saved receiver");
                smDrawerOther   = nvDrawer.Menu.AddSubMenu("Other");
                smDrawerDevices.SetGroupCheckable(0, true, false);

                int i = 0;
                foreach (var device in deviceHelper.liDevices)
                {
                    AddDrawerItem(
                        smDrawerDevices,
                        i,
                        device.scanDevice.Model,
                        Resource.Drawable.av_receiver_100_black,
                        true,
                        0,
                        Resource.Layout.layout_home_drawer_item_action, device.id.ToString());

                    if (device.conFlag > 0)
                    {
                        ConnectWithDevice(i);
                    }
                    i++;
                }

                AddDrawerItem(
                    smDrawerOther, 0, "Add device",
                    Resource.Drawable.add_100_white,
                    true, 1, null, null);
                AddDrawerItem(
                    smDrawerOther, 1, "Sleep timer",
                    Resource.Drawable.sleep_timer_100_black,
                    true, 1, null, null);
                AddDrawerItem(
                    smDrawerOther, 2, "Buy key",
                    Resource.Drawable.key_100_black,
                    true, 1, null, null);
                AddDrawerItem(
                    smDrawerOther, 3, "Help",
                    Resource.Drawable.help_100_black,
                    true, 1, null, null);

                nvDrawer.NavigationItemSelected += OnNavDrawerItemSelected;
                nvDrawer.BringToFront();

                if (prefs.IsFirstAppStart())
                {
                    ShowWelcomeDialog();
                }

                RegisterMedia();

                OpenBroadcast();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Toast.MakeText(this, e.Message, ToastLength.Long).Show();
            }
        }