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 = CountersFragment.NewInstance();
                break;

            case 1:
                fragment = AboutFragment.NewInstance();
                break;
            }

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, fragment)
            .Commit();
        }
Пример #2
0
        public override Android.Support.V4.App.Fragment GetItem(int position)
        {
            switch (position)
            {
            case 0: return(BrowseFragment.NewInstance());

            case 1: return(AboutFragment.NewInstance());
            }
            return(null);
        }
Пример #3
0
 public override Fragment GetItem(int position)
 {
     if (position == 1)
     {
         return(AboutFragment.NewInstance());
     }
     else
     {
         return(BrowseFragment.NewInstance());
     }
 }
        /// <summary>
        /// Changes the sidebar view of the app. Used when a user clicks on a menu item or to
        /// manually change the view
        /// </summary>
        /// <param name="id"> the id of the fragment that should be displayed</param>
        private bool ChangeNavigationView(int id)
        {
            Microsoft.Intune.Mam.Client.Support.V4.App.MAMFragment frag = null;

            switch (id)
            {
            case Resource.Id.nav_tasks:
                frag = new TasksFragment();
                break;

            case Resource.Id.nav_about:
                frag = new AboutFragment();
                break;

            case Resource.Id.nav_sign_out:
                AuthManager.GetManager().SignOut(this);
                break;

            default:     // If we don't recognize the id, go to the default (submit) rather than crashing
            case Resource.Id.nav_submit:
                frag = new SubmitFragment();
                break;
            }

            bool didChangeView = frag != null;

            if (didChangeView)
            {
                try
                {
                    // Display the fragment
                    Android.Support.V4.App.FragmentManager fragManager = SupportFragmentManager;
                    fragManager.BeginTransaction().Replace(Resource.Id.flContent, frag).Commit();
                }
                catch (NullReferenceException e)
                {
                    Console.WriteLine(e.StackTrace);
                    didChangeView = false;
                }
            }

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

            if (drawer != null)
            {
                drawer.CloseDrawer(Android.Support.V4.View.GravityCompat.Start);
            }
            return(didChangeView);
        }
Пример #5
0
 private void PopupMenu_MenuItemClick(object sender, PopupMenu.MenuItemClickEventArgs e)
 {
     if (e.Item.ItemId == 0)
     {
         HelpLineDialogFragment about = new HelpLineDialogFragment();
         SupportFragmentManager.BeginTransaction()
         .Replace(Resource.Id.fragHost, about)
         .Commit();
     }
     if (e.Item.ItemId == 1)
     {
         AboutFragment about = new AboutFragment();
         SupportFragmentManager.BeginTransaction()
         .Replace(Resource.Id.fragHost, about)
         .Commit();
     }
 }
Пример #6
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            AndroidX.Fragment.App.Fragment existingFragment;
            existingFragment = SupportFragmentManager.FindFragmentByTag("CHK");
            if (existingFragment != null)
            {
                SupportFragmentManager.PopBackStackImmediate(existingFragment.Id, 0);
            }
            existingFragment = SupportFragmentManager.FindFragmentByTag("STS");
            if (existingFragment != null)
            {
                SupportFragmentManager.PopBackStackImmediate(existingFragment.Id, 0);
            }
            existingFragment = SupportFragmentManager.FindFragmentByTag("ABT");
            if (existingFragment != null)
            {
                SupportFragmentManager.PopBackStackImmediate(existingFragment.Id, 0);
            }

            AndroidX.Fragment.App.Fragment fragment;
            if (item.ItemId == Resource.Id.menu_about)
            {
                _fragmentTag = "ABT";
                fragment     = AboutFragment.NewInstance();
                SupportActionBar.SetTitle(Resource.String.aboutTitle);
                _navigation.Visibility = ViewStates.Gone;
                _menu.FindItem(Resource.Id.menu_share).SetVisible(false);
                SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment, _fragmentTag).Commit();
            }

            if (item.ItemId == Resource.Id.menu_settings)
            {
                _fragmentTag = "SET";
                fragment     = SettingsFragment.NewInstance(_settingsService, Container.Resolve <IWorkerService>());
                SupportActionBar.SetTitle(Resource.String.settingsTitle);
                _navigation.Visibility = ViewStates.Gone;
                _menu.FindItem(Resource.Id.menu_share).SetVisible(false);
                SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment, _fragmentTag).Commit();
            }

            _eventService.OnMenuItemPressedEvent(new MenuItemPressedEventArgs(item.TitleFormatted.ToString(), _fragmentTag));
            //_eventService.OnSpareEvent(new EventArgs());
            return(base.OnOptionsItemSelected(item));
        }
Пример #7
0
        private void SetUpViewPager(ViewPager viewPager)
        {
            try
            {
                PostTab  = new UserPostFragment();
                AboutTab = new AboutFragment();

                var adapter = new MainTabAdapter(ChildFragmentManager);
                adapter.AddFragment(PostTab, "");
                adapter.AddFragment(AboutTab, "");

                viewPager.CurrentItem = 2;
                viewPager.Adapter     = adapter;
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Пример #8
0
        protected void BottomNavBarSetup(int id)
        {
            Fragment fragment = null;

            var bottomNavigation = FindViewById <BottomNavigationView>(Resource.Id.bottom_navigation);

            bottomNavigation.NavigationItemSelected += (s, e) =>
            {
                switch (e.Item.ItemId)
                {
                case Resource.Id.action_food:
                    fragment = FoodFragment.NewInstance();
                    break;

                case Resource.Id.action_drinks:
                    fragment = DrinksFragment.NewInstance();
                    break;

                case Resource.Id.action_reserve:
                    fragment = ReserveTableFragment.NewInstance();
                    break;

                case Resource.Id.action_events:
                    fragment = EventsFragment.NewInstance();
                    break;

                case Resource.Id.action_about:
                    fragment = AboutFragment.NewInstance();
                    break;
                }

                if (fragment == null)
                {
                    return;
                }

                FragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment).Commit();
            };
        }
        public void UpdateContent(Uri uri)
        {
            Fragment fragment;
            string tag;

            FragmentManager fm = SupportFragmentManager;
            FragmentTransaction tr = fm.BeginTransaction();

            if (CurrentContentFragmentTag != null)
            {
                Fragment currentFragment = fm.FindFragmentByTag(CurrentContentFragmentTag);
                if (currentFragment != null)
                {
                    tr.Hide(currentFragment);
                }
            }

            if (AboutFragment.ABOUT_URI.Equals(uri))
            {
                tag = AboutFragment.TAG;
                Fragment foundFragment = fm.FindFragmentByTag(tag);
                if (foundFragment != null)
                {
                    fragment = foundFragment;
                }
                else
                {
                    fragment = new AboutFragment();
                }
            }
            else if (SandboxFragment.SETTINGS_URI.Equals(uri))
            {
                tag = SandboxFragment.TAG;
                SandboxFragment foundFragment = (SandboxFragment)fm.FindFragmentByTag(tag);
                if (foundFragment != null)
                {
                    foundFragment.onSettingsChangedListener = mSettingsChangedListener;
                    fragment = foundFragment;
                }
                else
                {
                    SandboxFragment settingsFragment = new SandboxFragment();
                    settingsFragment.onSettingsChangedListener = mSettingsChangedListener;
                    fragment = settingsFragment;
                }
            }
            else if (uri != null)
            {
                tag = WebViewFragment.TAG;
                WebViewFragment webViewFragment;
                Fragment foundFragment = fm.FindFragmentByTag(tag);
                if (foundFragment != null)
                {
                    fragment = foundFragment;
                    webViewFragment = (WebViewFragment)fragment;
                }
                else
                {
                    webViewFragment = new WebViewFragment();
                    fragment = webViewFragment;
                }
                webViewFragment.Url = uri.ToString();
            }
            else
            {
                return;
            }

            if (fragment.IsAdded)
            {
                tr.Show(fragment);
            }
            else
            {
                tr.Add(Resource.Id.content, fragment, tag);
            }
            tr.Commit();

            CurrentUri = uri;
            CurrentContentFragmentTag = tag;
        }
Пример #10
0
        private void ListItemClicked(int position)
        {
            Android.Support.V4.App.Fragment fragment = null;
            switch (position)
            {
            case 0:
                this.Title = "Dashboard";
                fragment   = new DashboardFragment();
                break;

            case 1:
                this.Title = "Outlet List";
                fragment   = new OutletListFragment();
                break;

            case 2:
                this.Title = "Unit of Measurement";
                fragment   = new UOMFragment();
                break;

            case 3:
                this.Title = "Synchronization";
                fragment   = new SyncFragment();
                break;

            case 4:
                this.Title = "About";
                fragment   = new AboutFragment();
                break;

            case 5:
                Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);
                builder.SetTitle("Confirm");
                builder.SetMessage("Are you sure you want to log out?");
                builder.SetPositiveButton("NO", (sender, e) =>
                {
                });
                builder.SetNegativeButton("YES", (sender, e) =>
                {
                    var appPreferences = new AppPreferences(this.ApplicationContext);
                    appPreferences.SaveUsername("");
                    appPreferences.SavePassword("");
                    appPreferences.SaveMasterDBDownloaded(false);
                    appPreferences.SaveAuditDBDownloaded(false);

                    string masterDBPath = new FileUtil().GetMasterDBPath();
                    if (File.Exists(masterDBPath))
                    {
                        File.Delete(masterDBPath);
                    }

                    string auditDBPath = new FileUtil().GetAuditDBPath();
                    if (File.Exists(auditDBPath))
                    {
                        File.Delete(auditDBPath);
                    }

                    string auditDBBlankPath = new FileUtil().GetAuditDBBlankPath();
                    if (File.Exists(auditDBBlankPath))
                    {
                        File.Delete(auditDBBlankPath);
                    }

                    string tempZipFile = new FileUtil().GetTempZipFileName();
                    if (File.Exists(tempZipFile))
                    {
                        File.Delete(tempZipFile);
                    }

                    string tempDirectoryPath = new FileUtil().GetTempDirectoryPath();
                    string auditZipPath      = System.IO.Path.Combine(tempDirectoryPath, Core.Globals.LoginUsername + ".zip");
                    if (File.Exists(auditZipPath))
                    {
                        File.Delete(auditZipPath);
                    }

                    FileUtil.ClearCache();
                    FileUtil.DeleteCache(this.ApplicationContext);

                    GlobalsAndroid.masterDB = null;

                    GC.Collect();
                    GC.WaitForPendingFinalizers();

                    Finish();
                });
                builder.Show();
                return;
            }

            if (!IsFinishing)
            {
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .CommitAllowingStateLoss();
            }
        }
Пример #11
0
        public void Inject(AboutFragment fragment)
        {
            var container = Container.Create(modules);

            container.Inject(fragment);
        }
Пример #12
0
        public void UpdateContent(Uri uri)
        {
            Fragment fragment;
            string   tag;

            FragmentManager     fm = SupportFragmentManager;
            FragmentTransaction tr = fm.BeginTransaction();

            if (CurrentContentFragmentTag != null)
            {
                Fragment currentFragment = fm.FindFragmentByTag(CurrentContentFragmentTag);
                if (currentFragment != null)
                {
                    tr.Hide(currentFragment);
                }
            }

            if (AboutFragment.ABOUT_URI.Equals(uri))
            {
                tag = AboutFragment.TAG;
                Fragment foundFragment = fm.FindFragmentByTag(tag);
                if (foundFragment != null)
                {
                    fragment = foundFragment;
                }
                else
                {
                    fragment = new AboutFragment();
                }
            }
            else if (SandboxFragment.SETTINGS_URI.Equals(uri))
            {
                tag = SandboxFragment.TAG;
                SandboxFragment foundFragment = (SandboxFragment)fm.FindFragmentByTag(tag);
                if (foundFragment != null)
                {
                    foundFragment.onSettingsChangedListener = mSettingsChangedListener;
                    fragment = foundFragment;
                }
                else
                {
                    SandboxFragment settingsFragment = new SandboxFragment();
                    settingsFragment.onSettingsChangedListener = mSettingsChangedListener;
                    fragment = settingsFragment;
                }
            }
            else if (uri != null)
            {
                tag = WebViewFragment.TAG;
                WebViewFragment webViewFragment;
                Fragment        foundFragment = fm.FindFragmentByTag(tag);
                if (foundFragment != null)
                {
                    fragment        = foundFragment;
                    webViewFragment = (WebViewFragment)fragment;
                }
                else
                {
                    webViewFragment = new WebViewFragment();
                    fragment        = webViewFragment;
                }
                webViewFragment.Url = uri.ToString();
            }
            else
            {
                return;
            }

            if (fragment.IsAdded)
            {
                tr.Show(fragment);
            }
            else
            {
                tr.Add(Resource.Id.content, fragment, tag);
            }
            tr.Commit();

            CurrentUri = uri;
            CurrentContentFragmentTag = tag;
        }