Esempio n. 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            fab        = FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.Click += FabOnClick;

            DrawerLayout drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            // ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);
            //  drawer.AddDrawerListener(toggle);
            // toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.SetNavigationItemSelectedListener(this);

            fab.Visibility = ViewStates.Visible;
            UserDashBoardFragment newFragment = new UserDashBoardFragment();
            var ft = FragmentManager.BeginTransaction();

            ft.Replace(Resource.Id.container, newFragment);
            ft.Commit();
            this.Title = "Home";
        }
Esempio n. 2
0
        public override void OnBackPressed()
        {
            if (this.Title == "Home")
            {
                DialogHelper.ShowDialogAlert("Message"
                                             , "Do you want to Log Out?"
                                             , this, (senderAlert, args) =>
                {
                    sp = GetSharedPreferences("Login", FileCreationMode.Private);
                    sp.Edit().Clear().Commit();

                    var intent = new Intent(this, typeof(LoginActivity));
                    StartActivity(intent);
                    this.Finish();
                });
            }
            else
            {
                fab.Visibility = ViewStates.Visible;
                UserDashBoardFragment newFragment = new UserDashBoardFragment();
                var ft = FragmentManager.BeginTransaction();
                ft.Replace(Resource.Id.container, newFragment);
                ft.Commit();
                this.Title = "Home";
            }



            // FinishAffinity();
        }