示例#1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            V7Toolbar toolbar = FindViewById <V7Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);


            if (savedInstanceState == null)
            {
                Android.Support.V4.App.Fragment            newFragment = new HomeFragment();
                Android.Support.V4.App.FragmentTransaction ft          = SupportFragmentManager.BeginTransaction();
                ft.Add(Resource.Id.content_frame, newFragment);
                ft.AddToBackStack(null);
                ft.Commit();
            }
            drawer = (DrawerLayout)FindViewById(Resource.Id.drawer_layout);

            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.drawer_open, Resource.String.drawer_close);

            //ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            //        this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
            drawer.SetDrawerListener(toggle);
            toggle.SyncState();

            navigationView = (NavigationView)FindViewById(Resource.Id.nav_view);
            SetupDrawerContent(navigationView); //Calling Function


            DataEntryPoint.Instance.Init();
        }
示例#2
0
        private void BottomNavigation_NavigationItemSelected(object sender, BottomNavigationView.NavigationItemSelectedEventArgs e)
        {
            switch (e.Item.ItemId)
            {
            case Resource.Id.menu_home:
                fragment = HomeFragment.NewInstance();
                break;

            case Resource.Id.menu_workitem:
                var bundle = new Bundle();
                bundle.PutString("access_token", accessToken);
                fragment           = WorkItemFragment.NewInstance();
                fragment.Arguments = bundle;
                break;
                //case Resource.Id.menu_video:
                //    fragment = Fragment3.NewInstance();
                //    break;
            }

            if (fragment == null)
            {
                return;
            }
            Log.Debug("vsts", fragment.ToString());

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, fragment)
            .Commit();
        }
示例#3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            global::Xamarin.Forms.Forms.Init(this, bundle);
            SetContentView(Resource.Layout.Main);
            //  SQLiteClientBase<GlobalOption> globalOption = new SQLiteClientBase<GlobalOption>();


            //  var root = FindViewById<LinearLayout>(Resource.Id.ll_main_layout);

            /**
             * Intial view */
            InitView();


            navigationView.NavigationItemSelected += OnNavigationItemSelected;

            homeFragment         = new HomeFragment(this);
            settingsFragment     = new SettingsFragment(this);
            registrationFragment = new RegistrationFragment(this);
            mStackFragments      = new Stack <SupportFragment>();

            var trans = SupportFragmentManager.BeginTransaction();

            trans.Add(Resource.Id.fragmentContainer, homeFragment, "homeFragment");
            trans.Commit();

            mCurrentFragment = homeFragment;

            /**
             * get the theme
             */
        }
示例#4
0
        private void LoadFragment(int id)
        {
            Fragment fragment = null;

            switch (id)
            {
            case Resource.Id.menu_home:
                fragment = HomeFragment.NewInstance();
                break;

            case Resource.Id.menu_library:
                fragment = LibraryFragment.NewInstance();
                break;

            case Resource.Id.menu_search:
                fragment = SearchFragment.NewInstance();
                break;

            case Resource.Id.menu_menu:
                fragment = MenuFragment.NewInstance();
                break;
            }

            if (fragment == null)
            {
                return;
            }

            FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit();
        }
        void LoadFragment(int id)
        {
            Android.App.Fragment fragment = null;
            switch (id)
            {
            case Resource.Id.homeIcon:
                fragment = HomeFragment.NewInstance("", "");
                break;

            case Resource.Id.appointmentIcon:
                fragment = AppointmentFragment.NewInstance("", "");
                break;

            case Resource.Id.preorderIcon:
                fragment = PreOrderFragment.NewInstance("", "");
                break;

            case Resource.Id.accountIcon:
                fragment = AccountFragment.NewInstance("", "");
                break;
            }

            if (fragment == null)
            {
                return;
            }

            Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction();
            transaction.Replace(Resource.Id.frame_container, fragment);
            transaction.AddToBackStack(null);
            transaction.Commit();

            //FragmentManager.BeginTransaction().Replace(Resource.Id.frame_container, fragment).Commit();
        }
示例#6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            var toolbar = FindViewById <V7Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            var drawerToggle = new Android.Support.V7.App.ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.drawer_open, Resource.String.drawer_close);

            drawerLayout.SetDrawerListener(drawerToggle);
            drawerToggle.SyncState();
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            setupDrawerContent(navigationView);
            //var profile = FindViewById<ImageView>(Resource.Id.imageView1);
            //profile.SetImageResource(Resource.Drawable.person);


            //added newly
            Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
            HomeFragment home = new HomeFragment();

            transaction.Replace(Resource.Id.framelayout, home).AddToBackStack(null).Commit();
            //HomeFragment home = new HomeFragment();
            // transaction.Add(Resource.Id.framelayout, home).Commit();
            //SupportActionBar.SetDisplayHomeAsUpEnabled = true;
        }
示例#7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.home_navigation);
            // set toolbar
            var toolbar = FindViewById <Toolbar>(Resource.Id.main_toolbar);

            SetToolbar(toolbar);

            // set drawer
            var drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            SetDrawerLayout(drawerLayout, toolbar);


            // Attach item selected handler to navigation view
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected;

            // add view on main screen
            Fragment homeFragment = new HomeFragment();

            customFragment = new CustomFragmentManager();
            customFragment.AddFragment(this, homeFragment, "HomeFragment");
        }
示例#8
0
        private void LoadFragment(int id)
        {
            Fragment fragment = null;

            switch (id)
            {
            case Resource.Id.navigation_home:
                fragment = new HomeFragment();
                break;

            case Resource.Id.navigation_salons:
                fragment = new SalonsFragment(_salons);
                break;

            case Resource.Id.navigation_services:
                fragment = new ServicesFragment();
                break;

            case Resource.Id.navigation_appointments:
                fragment = new AppointmentFragment();
                break;
            }

            if (fragment == null)
            {
                return;
            }
            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.mainFrameLayout, fragment)
            .Commit();
        }
示例#9
0
        public bool LoadFragment(int item)
        {
            Fragment aFragment = null;

            switch (item)
            {
            case Resource.Id.navigation_home:
                aFragment = new HomeFragment();
                break;

            case Resource.Id.navigation_dashboard:
                aFragment = new DashboardFragment();
                break;

            case Resource.Id.navigation_notifications:
                aFragment = new NotificationFragment();
                break;
            }

            if (aFragment != null)
            {
                this.FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, aFragment).Commit();
            }

            return(false);
        }
示例#10
0
        void LoadFragment(int id)
        {
            Android.Support.V4.App.Fragment fragment = null;
            switch (id)
            {
            case Resource.Id.menu_home:
                fragment = HomeFragment.NewInstance();
                break;

            case Resource.Id.menu_users:
                fragment = UsersFragment.NewInstance();
                break;

            case Resource.Id.menu_account:
                fragment = AccountFragment.NewInstance();
                break;
            }
            if (fragment == null)
            {
                return;
            }

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, fragment)
            .Commit();
        }
示例#11
0
 private void Init()
 {
     _homeFragment         = new HomeFragment();
     _mineFragment         = new MineFragment();
     _listPageFragment     = new ListPageFragment();
     _recyclerViewFragment = new RecyclerViewFragment();
     handler = new UIHander(HandleiAction);
 }
示例#12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            var toolBar = FindViewById <Toolbar>(Resource.Id.toolbar);

            toolBar.SetTitle(Resource.String.app_name);
            SetSupportActionBar(toolBar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.menu2);

            var localDatas = Application.Context.GetSharedPreferences("MyDatas", Android.Content.FileCreationMode.Private);

            drawerLayout = FindViewById <Android.Support.V4.Widget.DrawerLayout>(Resource.Id.drawer_layout);
            navView      = FindViewById <NavigationView>(Resource.Id.nav_view);
            Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
            HomeFragment home = new HomeFragment();

            transaction.Add(Resource.Id.framelayout, home).Commit();

            var headerView = navView.GetHeaderView(0);

            lastName  = headerView.FindViewById <TextView>(Resource.Id.menuLastName);
            firstName = headerView.FindViewById <TextView>(Resource.Id.menuFirstName);
            userImage = headerView.FindViewById <ImageView>(Resource.Id.userImg);

            string data_lastName  = localDatas.GetString("LastName", "");
            string data_firstName = localDatas.GetString("FirstName", "");
            string data_uri       = localDatas.GetString("Uri", "");

            lastName.Text  = data_lastName;
            firstName.Text = data_firstName;

            Android.Net.Uri uri = Android.Net.Uri.Parse(data_uri);
            if (uri == null)
            {
                userImage.SetImageResource(Resource.Drawable.user);
            }
            else
            {
                userImage.SetImageURI(uri);
            }

            Spinner spinner = FindViewById <Spinner>(Resource.Id.spinner);

            spinner.ItemSelected += spinner_ItemSelected;
            var adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.curr_array, Resource.Layout.SpinnerItem);

            adapter.SetDropDownViewResource(Resource.Layout.SpinnerDropdown);
            spinner.Adapter = adapter;
            setupDrawerContent(navView);
        }
示例#13
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Instantiate Fragments
            mHomeFragment       = new HomeFragment();
            mDiscoverFragment   = new DiscoverFragment();
            mSubmitIdeaFragment = new SubmitIdeaFragment();
            mMyAccountFragment  = new MyAccountFragment();
            mPatentTreeFragment = new PatentTreeFragment();

            mStackFragment = new Stack <SupportFragment>();


            //var varEmailPage = FindViewById<Toolbar>(Resource.Id.toolbar);
            //SetActionBar(varTopToolbar);
            //ActionBar.Title = "SPARKWARE"

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "Sparkware";

            // Transactions are needed to change between pages
            var trans = SupportFragmentManager.BeginTransaction();

            // Add fragment to the tranaction and hide it (only 1 is needed to be shown at a time, the last one)
            trans.Add(Resource.Id.fragmentContainer, mPatentTreeFragment, "PatentTreeFragment");
            trans.Hide(mPatentTreeFragment);

            trans.Add(Resource.Id.fragmentContainer, mMyAccountFragment, "MyAccountFragment");
            trans.Hide(mMyAccountFragment);

            trans.Add(Resource.Id.fragmentContainer, mSubmitIdeaFragment, "SubmitIdeaFragment");
            trans.Hide(mSubmitIdeaFragment);

            trans.Add(Resource.Id.fragmentContainer, mDiscoverFragment, "DiscoverFragment");
            trans.Hide(mDiscoverFragment);

            trans.Add(Resource.Id.fragmentContainer, mHomeFragment, "HomeFragment");

            //trans.Add(Resource.Id.fragmentContainer, emailPage, "ActivityEmail");

            // Show fragments
            trans.Commit();

            // Tracks the current fragment being shown, right now it is the home fragment
            mCurrentFragment = mHomeFragment;
        }
示例#14
0
        public void SwitchHome()
        {
            FragmentTransaction transaction = fm.BeginTransaction();

            if (homeFragment == null)
            {
                homeFragment = new HomeFragment();
                transaction.Add(Resource.Id.frameContent, homeFragment).Commit();
            }
            else
            {
                transaction.Show(homeFragment).Commit();
            }
        }
示例#15
0
        private void ListItemClicked(int position)
        {
            //this way we don't load twice, but you might want to modify this a bit.
            if (position == oldPosition)
            {
                return;
            }

            oldPosition = position;

            Android.Support.V4.App.Fragment fragment = null;
            switch (position)
            {
            case 0:
                fragment = HomeFragment.NewInstance();
                break;

            case 1:
                fragment = LocationsFragment.NewInstance();
                break;

            case 2:
                fragment = AddItemBarcodeFragment.NewInstance();
                break;

            case 3:
                fragment = StoragesFragment.NewInstance();
                break;

            case 4:
                fragment = CategoriesFragment.NewInstance();
                break;

            case 5:
                fragment = ProductsFragment.NewInstance();
                break;

            case 6:
                fragment = ShopListFragment.NewInstance();
                break;

            case 7:
                fragment = SummaryFragment.NewInstance();
                break;
            }

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, fragment)
            .Commit();
        }
示例#16
0
 public override void OnBackPressed()
 {
     if (SupportActionBar.Title == "Home")
     {
         Android.App.FragmentTransaction transaction    = FragmentManager.BeginTransaction();
         DialogFragmentLogout            dialogLocation = new DialogFragmentLogout();
         dialogLocation.Show(transaction, "dialogue fragment");
     }
     else
     {
         SupportFragmentManager.BeginTransaction()
         .Replace(Resource.Id.content_frame, HomeFragment.NewInstance())
         .Commit();
     }
 }
示例#17
0
        void setupDrawerContent(NavigationView navigationView)
        {
            navigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);

                /*System.Console.WriteLine(e.MenuItem);
                 * if(e.MenuItem.ToString() == "Employee")
                 * {
                 *  //var intent = new Intent(this, typeof(Employee_Activity));
                 *  //StartActivity(intent);
                 *
                 * }*/

                //added new
                Android.App.FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                switch (e.MenuItem.TitleFormatted.ToString())
                {
                case "Test":
                    Test_Fragment test = new Test_Fragment();
                    transaction1.Replace(Resource.Id.framelayout, test).AddToBackStack(null).Commit();
                    break;

                case "Employee":
                    Employee_Fragment employee = new Employee_Fragment();
                    transaction1.Replace(Resource.Id.framelayout, employee).AddToBackStack(null).Commit();
                    break;

                case "Home":
                    HomeFragment home = new HomeFragment();
                    transaction1.Replace(Resource.Id.framelayout, home).AddToBackStack(null).Commit();
                    break;

                case "Discussion":
                    Discussion_Fragment discussion = new Discussion_Fragment();
                    transaction1.Replace(Resource.Id.framelayout, discussion).AddToBackStack(null).Commit();
                    break;

                case "QR code":
                    var intent = new Intent(this, typeof(QR_Activity));
                    StartActivity(intent);
                    break;
                }

                drawerLayout.CloseDrawers();
            };
        }
示例#18
0
        public bool OnNavigationItemSelected(IMenuItem menuItem)
        {
            if (menuItem.ItemId == Resource.Id.Menu_Navigation_Settings)
            {
                _navClosedAction = () => SettingsActivity.StartActivity(this);
                _navigationDrawer.CloseDrawer(GravityCompat.Start);
                return(false);
            }

            _selectedItem = menuItem;
            _selectedItem.SetChecked(true);

            switch (_selectedItem.ItemId)
            {
            case Resource.Id.Menu_Navigation_Home:
                ChangeFragment(HomeFragment.GetInstance() ?? new HomeFragment());
                break;

            case Resource.Id.Menu_Navigation_Anime:
                ChangeFragment(MediaListFragment.GetInstance(MediaListFragment.AnimeMediaListFragmentName) ??
                               MediaListFragment.CreateMediaListFragment(Settings.LoggedInUser?.Id ?? 0, MediaType.Anime));
                break;

            case Resource.Id.Menu_Navigation_Manga:
                ChangeFragment(MediaListFragment.GetInstance(MediaListFragment.MangaMediaListFragmentName) ??
                               MediaListFragment.CreateMediaListFragment(Settings.LoggedInUser?.Id ?? 0, MediaType.Manga));
                break;

            case Resource.Id.Menu_Navigation_Discover:
                ChangeFragment(new DiscoverFragment());
                break;

            //case Resource.Id.Menu_Navigation_CurrentSeason:
            //    ChangeFragment(new CurrentSeasonFragment());
            //    break;
            case Resource.Id.Menu_Navigation_TorrentSearch:
                ChangeFragment(new TorrentSearchFragment());
                break;

            case Resource.Id.Menu_Navigation_Browse:
                ChangeFragment(new BrowseFragment());
                break;
            }

            return(true);
        }
示例#19
0
        private void SetUpViewPager(ViewPager viewPager)
        {
            ViewPagerAdapter adapter = new ViewPagerAdapter(SupportFragmentManager);

            homeFragment     = new HomeFragment();
            libraryFragment  = new LibraryFragment();
            accountFragment  = new AccountFragment();
            userLandFragment = new AddNewLandFragment();

            adapter.AddFragment(homeFragment);               //0
            adapter.AddFragment(libraryFragment);            //1
            adapter.AddFragment(accountFragment);            //2
            adapter.AddFragment(userLandFragment);           //3
            adapter.AddFragment(new EditUserLandFragment()); //4
            adapter.AddFragment(new UserLandFragment());     //5

            viewPager.Adapter = adapter;
        }
示例#20
0
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            AndroidX.Fragment.App.Fragment selectedFragment = null;
            switch (item.ItemId)
            {
            case Resource.Id.navigation_home:
                selectedFragment = new HomeFragment();
                break;

            case Resource.Id.cardSet_dashboard:
                selectedFragment = new CardSetsFragment();
                break;

            case Resource.Id.setting_dashboard:
                selectedFragment = new SettingsFragment();
                break;
            }
            this.SupportFragmentManager.BeginTransaction().Replace(Resource.Id.fragment_container, selectedFragment).Commit();
            return(true);
        }
示例#21
0
 public void OnItemSelected(int id)
 {
     if (id == Resource.Id.navHome)
     {
         HomeFragment home = new HomeFragment();
         home.PanicButtonEventHandler += Home_PanicButtonEventHandler;
         SupportFragmentManager.BeginTransaction()
         .Replace(Resource.Id.fragHost, home)
         .Commit();
     }
     if (id == Resource.Id.navAwareness)
     {
         AwarenessFragment awareness = new AwarenessFragment();
         SupportFragmentManager.BeginTransaction()
         .Replace(Resource.Id.fragHost, awareness)
         .Commit();
     }
     if (id == Resource.Id.navForum)
     {
         ForumFragment forum = new ForumFragment();
         SupportFragmentManager.BeginTransaction()
         .Replace(Resource.Id.fragHost, forum)
         .Commit();
     }
     if (id == Resource.Id.navAlerts)
     {
         AlertsFragment alerts = new AlertsFragment();
         SupportFragmentManager.BeginTransaction()
         .Replace(Resource.Id.fragHost, alerts)
         .Commit();
         alerts.ShowMapHandler += Alerts_ShowMapHandler;
     }
     if (id == Resource.Id.navUserProfile)
     {
         ProfileFragment profile = new ProfileFragment();
         SupportFragmentManager.BeginTransaction()
         .Replace(Resource.Id.fragHost, profile)
         .Commit();
     }
 }
示例#22
0
        void LoadFragment(int id)
        {
            try
            {
                Android.Support.V4.App.Fragment fragment = null;
                switch (id)
                {
                case Resource.Id.navigation_home:
                    fragment = HomeFragment.NewInstance();
                    break;

                case Resource.Id.navigation_credit:
                    fragment = CreditFragment.NewInstance();
                    break;

                case Resource.Id.navigation_debit:
                    fragment = DebitFragment.NewInstance();
                    break;

                case Resource.Id.navigation_notifications:
                    fragment = NotificationFragment.NewInstance();
                    break;
                }

                if (fragment == null)
                {
                    return;
                }

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();
            }
            catch (Exception ex)
            {
                clsGLB.ShowMessage(ex.Message, this, MessageTitle.ERROR);
            }
        }
        private void LoadFragment(int position)
        {
            AndroidX.Fragment.App.Fragment fragment = null;
            Bundle bundle = new Bundle();

            switch (position)
            {
            case Resource.Id.navigation_home:
                fragment = new HomeFragment();
                bundle.PutString("Restaurant_List", Intent.GetStringExtra("Restaurant_List"));
                fragment.Arguments = bundle;
                break;

            case Resource.Id.navigation_recommendation:
                fragment = new RecommendFragment();
                bundle.PutInt("User_Id", selecteduser.UserId);
                fragment.Arguments = bundle;
                break;

            case Resource.Id.navigation_more_recommendation:
                fragment = new RecommendCategoryFragment();
                bundle.PutInt("User_Id", selecteduser.UserId);
                fragment.Arguments = bundle;
                break;

            case Resource.Id.navigation_visited:
                fragment = new VisitedFragment();
                bundle.PutInt("User_Id", selecteduser.UserId);
                fragment.Arguments = bundle;
                break;
            }
            if (fragment != null)
            {
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.main_content_frame, fragment)
                .Commit();
            }
        }
示例#24
0
        private void SetupDrawerContent(NavigationView navigationView)
        {
            navigationView.NavigationItemSelected += (sender, e) =>
            {
                Android.Support.V4.App.Fragment fragment = new HomeFragment();
                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.civil:
                    SetTitle(Resource.String.civil);
                    fragment = new CivilFragment();
                    break;

                case Resource.Id.military:
                    //fragment = new QuizzFragment();
                    break;

                case Resource.Id.business:
                    //fragment = new ScoresFragment();
                    break;

                case Resource.Id.heli:
                    //fragment = new AboutFragment();
                    break;
                }

                if (fragment != null)
                {
                    Android.Support.V4.App.FragmentTransaction ft = SupportFragmentManager.BeginTransaction();
                    ft.Replace(Resource.Id.content_frame, fragment);
                    ft.Commit();
                }

                e.MenuItem.SetChecked(true);
                drawer.CloseDrawers();
            };
        }
示例#25
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            SupportToolbar toolBar = FindViewById <SupportToolbar>(Resource.Id.toolBar);

            SetSupportActionBar(toolBar);

            SupportActionBar ab = SupportActionBar;

            ab.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
            ab.SetDisplayHomeAsUpEnabled(true);

            mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

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

            if (navigationView != null)
            {
                SetUpDrawerContent(navigationView);
            }

            FrameLayout viewPager = FindViewById <FrameLayout>(Resource.Id.container);

            exercisesFragment       = new ExercisesFragment();
            signInFragment          = new SignInFragment();
            signUpFragment          = new SignUpFragment();
            trainingProgramFragment = new TrainingProgramFragment();
            postureLevelFragment    = new PostureLevelFragment();
            chatsFragment           = new ChatsFragment();
            homeFragment            = new HomeFragment();

            Android.App.FragmentTransaction ftrans = FragmentManager.BeginTransaction();
            ftrans.Replace(Resource.Id.container, signInFragment).Commit();
        }
示例#26
0
        private void Bworker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            swipeRefresh.Refreshing = false;
            if (customer != null)
            {
                GenericFacade.UserName = username;
                GenericFacade.UserId   = customer.Id;

                swipeRefresh.Refreshing = false;

                Toast.MakeText(Activity, "Login successful", ToastLength.Long).Show();

                Fragment fragment = HomeFragment.NewInstance();
                FragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();

                ((MainActivity)Activity).ToggleLogin();
            }
            else
            {
                Toast.MakeText(Activity, "Please enter a valid username and password", ToastLength.Long).Show();
            }
        }
示例#27
0
        void setupDrawerContent(NavigationView navigationView)
        {
            navigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);
                Android.App.FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.navmain:
                    HomeFragment home = new HomeFragment();
                    transaction1.Replace(Resource.Id.framelayout, home).AddToBackStack(null).Commit();
                    break;

                case Resource.Id.navlist:
                    ProductFragment products = new ProductFragment();
                    transaction1.Replace(Resource.Id.framelayout, products).AddToBackStack(null).Commit();
                    break;

                case Resource.Id.navmap:
                    MapsFragment maps = new MapsFragment();
                    transaction1.Replace(Resource.Id.framelayout, maps).AddToBackStack(null).Commit();
                    break;

                case Resource.Id.navprice:
                    ExchangeRateFragment exchange = new ExchangeRateFragment();
                    transaction1.Replace(Resource.Id.framelayout, exchange).AddToBackStack(null).Commit();
                    break;

                case Resource.Id.navcalendar:
                    CalendarFragment calendar = new CalendarFragment();
                    transaction1.Replace(Resource.Id.framelayout, calendar).AddToBackStack(null).Commit();
                    break;
                }
                drawerLayout.CloseDrawers();
            };
        }
示例#28
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            ((MainActivity)Activity).SetAsDrawerToolbar();
            var ignored = base.OnCreateView(inflater, container, savedInstanceState);

            view     = inflater.Inflate(Resource.Layout.register, null);
            customer = new Customer();

            List <string> titles = new List <string>
            {
                "Please select a title"
            };

            titles.AddRange(Enum.GetNames(typeof(Title)).ToList());
            Spinner titleSpinner = view.FindViewById <Spinner>(Resource.Id.register_title);

            var adapter = new ArrayAdapter <string>(Activity, Android.Resource.Layout.SimpleSpinnerDropDownItem, titles);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            titleSpinner.Adapter = adapter;

            int initialSpinnerPosition = titleSpinner.SelectedItemPosition;

            titleSpinner.ItemSelected += (sender, args) =>
            {
                if (args.Position != initialSpinnerPosition)
                {
                    customer.Title = titles[args.Position];
                }
            };

            Button register = view.FindViewById <Button>(Resource.Id.register_btn);

            register.Click += delegate
            {
                string password        = view.FindViewById <TextView>(Resource.Id.register_password).Text;
                string confirmPassword = view.FindViewById <TextView>(Resource.Id.register_password_confirm).Text;

                customer.UserName          = view.FindViewById <TextView>(Resource.Id.register_username).Text;
                customer.Forename          = view.FindViewById <TextView>(Resource.Id.register_forename).Text;
                customer.Surname           = view.FindViewById <TextView>(Resource.Id.register_surname).Text;
                customer.DoB               = view.FindViewById <DatePicker>(Resource.Id.register_dob).DateTime;
                customer.AddressStreet     = view.FindViewById <TextView>(Resource.Id.register_street).Text;
                customer.AddressTown       = view.FindViewById <TextView>(Resource.Id.register_town).Text;
                customer.AddressCounty     = view.FindViewById <TextView>(Resource.Id.register_county).Text;
                customer.AddressPostalCode = view.FindViewById <TextView>(Resource.Id.register_postal_code).Text;
                customer.HomePhoneNo       = view.FindViewById <TextView>(Resource.Id.register_home_phone_no).Text;
                customer.WorkPhoneNo       = view.FindViewById <TextView>(Resource.Id.register_work_phone_no).Text;
                customer.MobilePhoneNo     = view.FindViewById <TextView>(Resource.Id.register_mobile_phone_no).Text;
                customer.Email             = view.FindViewById <TextView>(Resource.Id.register_email_address).Text;

                if (Validate())
                {
                    if (_authFacade.Register(customer.UserName, password, confirmPassword))
                    {
                        _authFacade.GetToken(customer.UserName, password);

                        GenericFacade.UserName = customer.UserName;

                        string owinId = _authFacade.GetUserId();

                        GenericFacade.OwinId = owinId;
                        _authFacade.AddCustomerRole();

                        customer.OwinUserId = owinId;

                        Customer newCustomer = _customerFacade.Create(customer).Result;

                        GenericFacade.UserId = newCustomer.Id;

                        Toast.MakeText(Activity, "Registration successful", ToastLength.Long).Show();

                        Fragment fragment = HomeFragment.NewInstance();
                        FragmentManager.BeginTransaction()
                        .Replace(Resource.Id.content_frame, fragment)
                        .Commit();

                        ((MainActivity)Activity).ToggleLogin();
                    }
                    else
                    {
                        Toast.MakeText(Activity, "An error occured whilst registering. Please try again later", ToastLength.Long).Show();
                    }
                }
                else
                {
                    Toast.MakeText(Activity, "Validation errors detected", ToastLength.Long).Show();
                }
            };

            return(view);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Home);

            this.title = this.drawerTitle = this.Title;

            this.drawerLayout = this.FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            this.drawerListView = this.FindViewById <ListView>(Resource.Id.left_drawer);


            //Create Adapter for drawer List
            this.drawerListView.Adapter  = new MenuListAdapter(this);
            drawerListView.DividerHeight = 0;


            //Set click handler when item is selected
            this.drawerListView.ItemClick += (sender, args) => ListItemClicked(args.Position);

            //Set Drawer Shadow
            this.drawerLayout.SetDrawerShadow(Resource.Drawable.drawer_shadow_dark, (int)GravityFlags.Start);

            //DrawerToggle is the animation that happens with the indicator next to the actionbar
            this.drawerToggle = new MyActionBarDrawerToggle(this, this.drawerLayout,
                                                            Resource.Drawable.action_menu,
                                                            Resource.String.drawer_open,
                                                            Resource.String.drawer_close);

            //Display the current fragments title and update the options menu
            this.drawerToggle.DrawerClosed += (o, args) => {
                this.ActionBar.Title = this.title;
                this.InvalidateOptionsMenu();
            };

            //Display the drawer title and update the options menu
            this.drawerToggle.DrawerOpened += (o, args) => {
                this.ActionBar.Title = this.drawerTitle;
                this.InvalidateOptionsMenu();
            };

            //Set the drawer lister to be the toggle.
            this.drawerLayout.SetDrawerListener(this.drawerToggle);

            Android.Support.V4.App.Fragment fragment = new HomeFragment(this);

            SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit();


            this.ActionBar.SetDisplayHomeAsUpEnabled(true);
            this.ActionBar.SetHomeButtonEnabled(true);

            //************************************************//
            LinearLayout lLayout = new LinearLayout(this);

            lLayout.SetGravity(GravityFlags.CenterVertical);
            LinearLayout.LayoutParams textViewParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);
            //textViewParameters.RightMargin = (int)(30 * this.Resources.DisplayMetrics.Density);

            TextView myTitle = new TextView(this);

            myTitle.Text     = "Home";
            myTitle.TextSize = 20;

            myTitle.Gravity = GravityFlags.Center;
            lLayout.AddView(myTitle, textViewParameters);

            ActionBar.LayoutParams actionbarParams = new ActionBar.LayoutParams(ActionBar.LayoutParams.MatchParent, ActionBar.LayoutParams.MatchParent);
            this.ActionBar.SetCustomView(lLayout, actionbarParams);
            this.ActionBar.SetDisplayShowCustomEnabled(true);
            //************************************************//



            SetPayment.Set("none");
            Settings.Frequency       = 0;
            Settings.IsFuturePayment = false;
            SendAppsDetail();

            Keyboard.HideSoftKeyboard(this);
        }
        private void ListItemClicked(int position)
        {
            //this way we don't load twice, but you might want to modify this a bit.
            if (position == oldPosition)
            {
                return;
            }

            oldPosition = position;

            Fragment fragment = null;

            switch (position)
            {
            case 0:
                fragment = HomeFragment.NewInstance();
                break;

            case 1:
                fragment = RestaurantIndexFragment.NewInstance();
                break;

            case 2:
                fragment = MenuIndexFragment.NewInstance();
                break;

            case 3:
                fragment = LoginFragment.NewInstance();
                break;

            case 4:
                fragment = RegisterFragment.NewInstance();
                break;

            case 5:
                fragment = UserDetailsFragment.NewInstance();
                break;

            case 6:
                fragment = BookingIndexFragment.NewInstance();
                break;

            case 7:
                new Android.App.AlertDialog.Builder(this).
                SetIcon(Android.Resource.Drawable.IcDialogAlert).
                SetTitle("Confirm").
                SetMessage("Are you sure you want to logout?").
                SetPositiveButton("Yes", (c, ev) =>
                {
                    GenericFacade.Token    = "";
                    GenericFacade.UserName = "";
                    GenericFacade.UserId   = 0;
                    ToggleLogout();
                }).
                SetNegativeButton("No", (c, ev) =>
                {
                }).
                Show();
                break;

            case 8:
                ExitApp();
                break;
            }

            if (fragment != null)
            {
                FragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();
            }
        }