Ejemplo n.º 1
0
 public override void OnClick(Android.App.Fragment source, int buttonId, object context = null)
 {
     // only handle input if the springboard is closed
     if (NavbarFragment.ShouldTaskAllowInput( ))
     {
         // if the main page is the source
         if (source == MainPage)
         {
             // and it's button id 0, goto the create page
             if (buttonId == 0)
             {
                 PresentFragment(CreatePage, true);
             }
         }
         else if (source == CreatePage)
         {
             if (buttonId == 0)
             {
                 PostPage.PrayerRequest = (Rock.Client.PrayerRequest)context;
                 PresentFragment(PostPage, true);
             }
         }
         else if (source == PostPage)
         {
             // this is our first / only "circular" navigation, as we're returning to the main page after
             // having posted a prayer. In which case, clear the back stack.
             NavbarFragment.FragmentManager.PopBackStack(null, PopBackStackFlags.Inclusive);
             PresentFragment(MainPage, false);
         }
     }
 }
Ejemplo n.º 2
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            base.OnOptionsItemSelected(item);
            if (mViewPager == null)
            {
                Logger.Info(Tag, "onOptionsItemSelected viewpager is null");
                return(false);
            }
            if (mTabsAdapter == null)
            {
                Logger.Info(Tag, "onOptionsItemSelected mTabsAdapter is null");
                return(false);
            }
            int     currentItem = mViewPager.CurrentItem;
            TabInfo tabInfo     = mTabsAdapter.GetTabInfo(currentItem);

            Android.App.Fragment fragment = tabInfo.Fragment;

            if (fragment == null)
            {
                Logger.Info(Tag, "onOptionsItemSelected fragment is null");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
 //  Methode om fragments te weergeven
 private void ShowFragment(Android.App.Fragment fragment)
 {
     Android.App.FragmentTransaction fragmentTransaction = FragmentManager.BeginTransaction();
     fragmentTransaction.Replace(Resource.Id.content_main, fragment)
     .AddToBackStack(null)
     .Commit();
 }
Ejemplo n.º 5
0
        void ListItemClicked(int position)
        {
            FragmentManager.PopBackStack(null, PopBackStackFlags.Inclusive);

            Log.Debug(Tag, "Item {0} has been selected.", position);

            Android.App.Fragment fragment = null;
            switch (position)
            {
            case 0:
                fragment = new SessionListFragment();
                break;

            case 1:
                fragment = new SpeakerListFragment();
                break;

            case 2:
                fragment = new AboutFragment();
                break;
            }

            // Insert the fragment by replacing any existing fragment
            FragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, fragment)
            .Commit();

            // Highlight the selected item, update the title, and close the drawer
            drawerList.SetItemChecked(position, true);
            Title = sections [position];
            drawerLayout.CloseDrawer(drawerList);
        }
Ejemplo n.º 6
0
        void AddTab(string tabText, int iconResourceId, Fragment view)
        {
            var tab = this.ActionBar.NewTab();
            tab.SetText(tabText);
            //tab.SetIcon(Resource.Drawable.ic_tab_white);

            // must set event handler before adding tab
            tab.TabSelected += delegate(object sender, ActionBar.TabEventArgs e)
            {
                if (view != null)
                {
                    var fragment = this.FragmentManager.FindFragmentById(Resource.Id.fragmentContainer);
                    if (fragment != null)
                        e.FragmentTransaction.Remove(fragment);
                    e.FragmentTransaction.Add(Resource.Id.fragmentContainer, view);
                }
                else
                {
                    Intent intent = new Intent(Application.Context, typeof(LoginActivity));
                    StartActivity(intent);
                }
                
            };
            tab.TabUnselected += delegate(object sender, ActionBar.TabEventArgs e)
            {
                e.FragmentTransaction.Remove(view);
            };

            this.ActionBar.AddTab(tab);
        }
Ejemplo n.º 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            lastFragments = new List <Android.App.Fragment>();
            description   = DataManager.GetInstance().Description();

            SetContentView(Resource.Layout.activity_main);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

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

            fab.Click += FabOnClick;

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

            ActionBarDrawerToggle toggle = new Android.Support.V7.App.ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);

            drawer.AddDrawerListener(toggle);
            toggle.SyncState();


            var detailsFrag = DescriptionFragment.NewInstance();

            if (currentFragment == null)
            {
                currentFragment = detailsFrag;
            }
            ChangeFragment(currentFragment);

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

            navigationView.SetNavigationItemSelectedListener(this);
        }
Ejemplo n.º 8
0
        void TabOnTabSelected(object sender, Android.App.ActionBar.TabEventArgs tabEventArgs)
        {
            var tab = (Android.App.ActionBar.Tab)sender;

            //  Log.Debug(Tag, "The tab {0} has been selected.", tab.Text);
            Android.App.Fragment frag = _fragments[tab.Position];
            tabEventArgs.FragmentTransaction.Replace(Resource.Id.frameLayout1, frag);
        }
Ejemplo n.º 9
0
 private void MAdapter_ItemClick(object sender, int i)
 {
     MainActivity.IsNavDisabled = true;
     Android.App.Fragment fragment = BookingViewFragment.NewInstance(bookings[i].Id);
     FragmentManager.BeginTransaction()
     .Replace(Resource.Id.content_frame, fragment)
     .AddToBackStack(null)
     .Commit();
 }
Ejemplo n.º 10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            int playId = Intent.GetIntExtra("PlayId", 0);

            Android.App.Fragment fragment = ContentFragment.GetInstance(playId);
            FragmentManager.BeginTransaction().Add(Android.Resource.Id.Content, fragment, "1").Commit();
        }
Ejemplo n.º 11
0
        private async void ViewModelOnMainNavigationRequestedFirst(Fragment fragment)
        {
            ViewModel.MainNavigationRequested -= ViewModelOnMainNavigationRequestedFirst;

            await Task.Delay(1000);

            if (ViewModel.CurrentMainPage != PageIndex.PageLogIn)
            {
                RequestedOrientation = ScreenOrientation.Unspecified;
            }
        }
Ejemplo n.º 12
0
 public void ChangeFragment(Android.App.Fragment frag)
 {
     if (FragmentManager.FindFragmentById(Resource.Id.container) == null)
     {
         FragmentManager.BeginTransaction()
         .Add(Resource.Id.container, frag)
         .Commit();
     }
     else
     {
         FragmentManager.BeginTransaction()
         .Replace(Resource.Id.container, frag)
         .Commit();
     }
 }
Ejemplo n.º 13
0
 private void ViewModelOnMainNavigationRequested(Fragment fragment)
 {
     try
     {
         _lastFragment = fragment;
         var trans = FragmentManager.BeginTransaction();
         trans.SetCustomAnimations(Resource.Animator.animation_slide_btm,
                                   Resource.Animator.animation_fade_out,
                                   Resource.Animator.animation_slide_btm,
                                   Resource.Animator.animation_fade_out);
         trans.Replace(Resource.Id.MainContentFrame, fragment);
         trans.CommitAllowingStateLoss();
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 14
0
        /*public override bool OnCreateOptionsMenu (IMenu menu)
         * {
         *
         *      var drawerOpen = _Drawer.IsDrawerOpen(_DrawerList);
         *      //when open don't show anything
         *      for (int i = 0; i < menu.Size(); i++)
         *              menu.GetItem(i).SetVisible(!drawerOpen);
         *
         *
         *      return base.OnCreateOptionsMenu(menu);
         * }*/

        public override bool OnKeyDown(Android.Views.Keycode keyCode, Android.Views.KeyEvent e)
        {
            Android.App.Fragment fragment = null;

            foreach (string sec in MenuItems)
            {
                fragment = FragmentManager.FindFragmentByTag(sec.ToLower());

                if (fragment == null)
                {
                    continue;
                }

                if (fragment.GetType() == typeof(EdicolaFragment))
                {
                    var f = fragment as EdicolaFragment;

                    if (!f.OnBackPressed())
                    {
                        return(false);
                    }
                }
                else if (fragment.GetType() == typeof(DownloadFragment))
                {
                    var f = fragment as DownloadFragment;

                    if (!f.OnBackPressed())
                    {
                        return(false);
                    }
                }
            }

            /*EdicolaFragment fragment = SupportFragmentManager.FindFragmentByTag("edicola") as EdicolaFragment;
             *
             * if(keyCode == Keycode.Back)
             * {
             *      if(!fragment.OnBackPressed())
             *      {
             *              return false;
             *      }
             * }*/

            return(base.OnKeyDown(keyCode, e));
        }
Ejemplo n.º 15
0
        public void ShowHistory()
        {
            if (_history == null)
            {
                // #1 Initialize
                Forms.Init(this, null);
                // #2 Use it
                _history = new HistoryPage().CreateFragment(this);
            }


            // And push that fragment onto the stack
            FragmentTransaction ft = FragmentManager.BeginTransaction();

            ft.AddToBackStack(null);
            ft.Replace(Resource.Id.fragment_frame_layout, _history, "history");

            ft.Commit();
        }
Ejemplo n.º 16
0
        private void Pts_LongClick(object sender, System.EventArgs e)
        {
            Android.App.FragmentTransaction ft = FragmentManager.BeginTransaction();
            //Remove fragment else it will crash as it is already added to backstack
            Android.App.Fragment prev = FragmentManager.FindFragmentByTag("dialog");
            if (prev != null)
            {
                ft.Remove(prev);
            }
            ft.AddToBackStack(null);

            var zz = chbnl;

            // Create and show the dialog.
            CoursePar_DialogFragment newFragment = CoursePar_DialogFragment.NewInstance(null, course.ID, holeNumber, 99);

            newFragment.Dismissed += NewFragment_Dismissed;                                                                                                                                       //Add fragment
            newFragment.Show(ft, "dialog");
        }
Ejemplo n.º 17
0
        void AddTab(string tabText, Android.App.Fragment view)
        {
            var tab = this.ActionBar.NewTab();

            tab.SetText(tabText);

            tab.TabSelected += delegate(object sender, ActionBar.TabEventArgs e) {
                var fragment = this.FragmentManager.FindFragmentById(Resource.Id.frameLayout1);
                if (fragment != null)
                {
                    e.FragmentTransaction.Remove(fragment);
                }
                e.FragmentTransaction.Add(Resource.Id.frameLayout1, view);
            };
            tab.TabUnselected += delegate(object sender, ActionBar.TabEventArgs e) {
                e.FragmentTransaction.Remove(view);
            };

            this.ActionBar.AddTab(tab);
        }
Ejemplo n.º 18
0
        private void SelectItem(object sender, AdapterView.ItemClickEventArgs e)
        {
            Fragment fragment = null;

            switch (e.Position)
            {
            case 0:
                fragment = new PlannerDailyFragment();
                break;

            case 1:
                fragment = new PlannerWeeklyFragment();
                break;

            case 2:
                fragment = new SettingsFragment();
                break;

            case 3:
                //TODO logout here
                if (!_Preferences.DemoMode)
                {
                    // Make sure we're not running in demo mode, then logout and redirect to the login fragment.
                    Logout();

                    // Destroy the local cookie.
                    _Preferences.AuthenticationCookie = default(Cookie);
                    fragment = new LoginFragment();
                }
                break;
            }

            if (fragment != null)
            {
                // Load the requested fragment.
                FragmentManager.BeginTransaction()
                .Replace(Resource.Id.content, fragment)
                .AddToBackStack(null)
                .Commit();
            }
        }
Ejemplo n.º 19
0
        void AddTab(string tabText, int iconResourceId, Fragment view)
        {
            var tab = this.ActionBar.NewTab();

            tab.SetText(tabText);
            //tab.SetIcon(Resource.Drawable.ic_tab_white);

            // must set event handler before adding tab
            tab.TabSelected += delegate(object sender, ActionBar.TabEventArgs e)
            {
                var fragment = this.FragmentManager.FindFragmentById(Resource.Id.fragmentContainer);
                if (fragment != null)
                {
                    e.FragmentTransaction.Remove(fragment);
                }
                e.FragmentTransaction.Add(Resource.Id.fragmentContainer, view);
            };
            tab.TabUnselected += delegate(object sender, ActionBar.TabEventArgs e)
            {
                e.FragmentTransaction.Remove(view);
            };

            this.ActionBar.AddTab(tab);
        }
Ejemplo n.º 20
0
        private void selectItem(int position)
        {
            switch (position)
            {
            case 0:
            {
                //Dashboard
                fragment = DashboardFragment.NewInstance();
                var fragmentManager = this.FragmentManager;
                var ft = FragmentManager.BeginTransaction();
                ft.Replace(Resource.Id.content_frame, fragment);
                ft.Commit();
                break;
            }

            case 1:
            {
                //Settings
                var fragment        = SettingsFragment.NewInstance();
                var fragmentManager = this.FragmentManager;
                var ft = FragmentManager.BeginTransaction();
                ft.Replace(Resource.Id.content_frame, fragment);
                ft.Commit();
                break;
            }

            case 2:
                //Logout
                LogoutAsync();
                break;
            }

            // update selected item title, then close the drawer
            Title = mOptionsTitles [position];
            mDrawerLayout.CloseDrawer(mDrawerList);
        }
Ejemplo n.º 21
0
        private void SetUpDrawerContent(NavigationView navigationView)
        {
            navigationView.NavigationItemSelected += (object sender, NavigationView.NavigationItemSelectedEventArgs e) =>
            {
                Android.App.FragmentTransaction ftrans   = FragmentManager.BeginTransaction();
                Android.App.Fragment            fragment = new Android.App.Fragment();

                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_exercises:
                    SetTitle(Resource.String.exercises_title);
                    fragment = exercisesFragment;
                    break;

                case Resource.Id.nav_home:
                    SetTitle(Resource.String.home_title);
                    if (GetToken() != "")
                    {
                        fragment = homeFragment;
                    }
                    else
                    {
                        fragment = signInFragment;
                    }
                    break;

                case Resource.Id.nav_signin:
                    SetTitle(Resource.String.signin_title);
                    ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
                    ISharedPreferencesEditor editor = prefs.Edit();
                    editor.PutString("access_token", "");
                    editor.Apply();
                    fragment = new SignInFragment();
                    break;

                case Resource.Id.nav_signup:
                    SetTitle(Resource.String.signup_title);
                    fragment = new SignUpFragment();
                    break;

                case Resource.Id.nav_chats:
                    SetTitle(Resource.String.chats_title);
                    if (GetToken() != "")
                    {
                        fragment = chatsFragment;
                    }
                    else
                    {
                        fragment = signInFragment;
                    }
                    break;

                case Resource.Id.nav_posturelevel:
                    SetTitle(Resource.String.posturelevel_title);
                    if (GetToken() != "")
                    {
                        fragment = postureLevelFragment;
                    }
                    else
                    {
                        fragment = signInFragment;
                    }
                    break;

                case Resource.Id.nav_program:
                    SetTitle(Resource.String.program_title);
                    if (GetToken() != "")
                    {
                        fragment = trainingProgramFragment;
                    }
                    else
                    {
                        fragment = signInFragment;
                    }
                    break;
                }


                if (GetToken() != "")
                {
                    navigationView.Menu.GetItem(5).SetTitle("Sign Out");
                }
                else
                {
                    navigationView.Menu.GetItem(5).SetTitle("Sign In");
                }

                e.MenuItem.SetChecked(true);
                mDrawerLayout.CloseDrawers();
                ftrans.Replace(Resource.Id.container, fragment).Commit();
            };
        }
Ejemplo n.º 22
0
                public override void OnClick(Android.App.Fragment source, int buttonId, object context = null)
                {
                    // only handle input if the springboard is closed
                    if (NavbarFragment.ShouldTaskAllowInput( ))
                    {
                        // decide what to do.
                        if (source == MainPage)
                        {
                            // on the main page, if the buttonId was -1, the user tapped the header,
                            // so we need to either go to the Watch or Take Notes page
                            if (buttonId == -1)
                            {
                                // the context is the button they clicked (watch or take notes)
                                int buttonChoice = (int)context;

                                // 0 is listen
                                if (buttonChoice == 0)
                                {
                                    ListenPage.MediaUrl = MainPage.SeriesEntries[0].Series.Messages[0].AudioUrl;
                                    ListenPage.ShareUrl = MainPage.SeriesEntries[0].Series.Messages[0].ShareUrl;
                                    ListenPage.Name     = MainPage.SeriesEntries[0].Series.Messages[0].Name;
                                    PresentFragment(ListenPage, true);
                                }
                                // 1 is watch
                                else if (buttonChoice == 1)
                                {
                                    WatchPage.MediaUrl = MainPage.SeriesEntries[0].Series.Messages[0].WatchUrl;
                                    WatchPage.ShareUrl = MainPage.SeriesEntries[0].Series.Messages[0].ShareUrl;
                                    WatchPage.Name     = MainPage.SeriesEntries[0].Series.Messages[0].Name;
                                    PresentFragment(WatchPage, true);
                                }
                                // 2 is read
                                else if (buttonChoice == 2)
                                {
                                    NotesPage.NoteUrl  = MainPage.SeriesEntries[0].Series.Messages[0].NoteUrl;
                                    NotesPage.NoteName = MainPage.SeriesEntries[0].Series.Messages[0].Name;

                                    PresentFragment(NotesPage, true);
                                }
                                // 3 is discussion guide
                                else if (buttonChoice == 3)
                                {
                                    DiscGuidePage.DiscGuideURL = MainPage.SeriesEntries[0].Series.Messages[0].DiscussionGuideUrl;
                                    PresentFragment(DiscGuidePage, true);
                                }
                            }
                            else
                            {
                                DetailsPage.Series = MainPage.SeriesEntries[buttonId].Series;
                                PresentFragment(DetailsPage, true);
                            }
                        }
                        else if (source == DetailsPage)
                        {
                            // the context is the button they clicked (watch or take notes)
                            int buttonChoice = (int)context;

                            // 0 is listen
                            if (buttonChoice == 0)
                            {
                                ListenPage.MediaUrl = DetailsPage.Series.Messages[buttonId].AudioUrl;
                                ListenPage.ShareUrl = DetailsPage.Series.Messages[buttonId].ShareUrl;
                                ListenPage.Name     = DetailsPage.Series.Messages[buttonId].Name;
                                PresentFragment(ListenPage, true);
                            }
                            // 1 is watch
                            else if (buttonChoice == 1)
                            {
                                WatchPage.MediaUrl = DetailsPage.Series.Messages[buttonId].WatchUrl;
                                WatchPage.ShareUrl = DetailsPage.Series.Messages[buttonId].ShareUrl;
                                WatchPage.Name     = DetailsPage.Series.Messages[buttonId].Name;
                                PresentFragment(WatchPage, true);
                            }
                            // 2 is read
                            else if (buttonChoice == 2)
                            {
                                NotesPage.NoteUrl  = DetailsPage.Series.Messages[buttonId].NoteUrl;
                                NotesPage.NoteName = DetailsPage.Series.Messages[buttonId].Name;

                                PresentFragment(NotesPage, true);
                            }
                            // 3 is discussion guide
                            else if (buttonChoice == 3)
                            {
                                DiscGuidePage.DiscGuideURL = DetailsPage.Series.Messages[buttonId].DiscussionGuideUrl;
                                PresentFragment(DiscGuidePage, true);
                            }
                        }
                        else if (source == NotesPage)
                        {
                            NotesFragment.UrlClickParams clickParams = (NotesFragment.UrlClickParams)context;

                            if (Springboard.IsAppURL(clickParams.Url) == true)
                            {
                                NavbarFragment.HandleAppURL(clickParams.Url);
                            }
                            else if (App.Shared.BibleRenderer.IsBiblePrefix(clickParams.Url))
                            {
                                BiblePassagePage            = new BiblePassageFragment(clickParams.Url);
                                BiblePassagePage.ParentTask = this;
                                PresentFragment(BiblePassagePage, true);
                            }
                            else
                            {
                                // the context is the activeURL to visit.
                                WebViewPage.DisableIdleTimer = true;
                                TaskWebFragment.HandleUrl(clickParams.UseExternalBrowser,
                                                          clickParams.UseImpersonationToken,
                                                          clickParams.Url,
                                                          this,
                                                          WebViewPage);
                            }
                        }
                        else if (source == DiscGuidePage)
                        {
                            // Discussion Guide page only has one button, so if it was clicked,
                            // let them view the guide.

                            WebViewPage.DisableIdleTimer = true;
                            TaskWebFragment.HandleUrl(true,
                                                      false,
                                                      DiscGuidePage.DiscGuideURL,
                                                      this,
                                                      WebViewPage);
                        }
                    }
                }
Ejemplo n.º 23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main_layout);

            #region varDeclaration
            metrics      = Resources.DisplayMetrics;
            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navView      = FindViewById <NavigationView>(Resource.Id.nav_view);
            menu         = navView.Menu;
            //floatBtn = FindViewById<FloatingActionButton>(Resource.Id.f)
            env            = new OmniPlaceEnvironment();
            DeviceDpWidth  = ConvertPxToDp(metrics.WidthPixels);
            DeviceDpHeight = ConvertPxToDp(metrics.HeightPixels);
            DevicePxWidth  = ConvertDpToPx(DeviceDpWidth);
            DevicePxHeight = ConvertDpToPx(DeviceDpHeight);
            console        = FindViewById <TextView>(Resource.Id.mainActivity_txtConsole);
            catListView    = FindViewById <ListView>(Resource.Id.catView_ListView);
            catListAdapter = new categoryAdapter(this, env.getDB());
            #endregion

            env.initializeDB();
            catListView.Adapter = catListAdapter;

            #region toolbar config
            var customtoolbar = FindViewById <v7Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(customtoolbar);
            SupportActionBar.Title = "OmniPlace";
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            //SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu_white_24dp); //open side menu image button
            #endregion
            #region MenuActions
            //control de acciones del menu, swapear entre fragments
            navView.NavigationItemSelected += (sender, e) =>
            {
                Android.App.Fragment fragment = null;

                switch (e.MenuItem.ItemId)
                {
                    #region codigoViejo
                    //case Resource.Id.nav_campSites:
                    //	SupportActionBar.Title = "CampApp - Sitios de Acampar";
                    //	logo_container.SetImageResource(0);
                    //	fragment = new frg_campingSites();
                    //	break;
                    //case Resource.Id.nav_climbSites:
                    //	SupportActionBar.Title = "CampApp - Rutas de escalada";
                    //	logo_container.SetImageResource(0);
                    //	fragment = new frg_climbingSites();
                    //	break;
                    //case Resource.Id.nav_Restaurants:
                    //	SupportActionBar.Title = "CampApp - Restaurantes";
                    //	logo_container.SetImageResource(0);
                    //	fragment = new frg_restaurants();
                    //	break;
                    //case Resource.Id.nav_uber:
                    //	try
                    //	{
                    //		var uri = Android.Net.Uri.Parse("market://details?id=com.ubercab");
                    //		Intent intent = new Intent(Intent.ActionView, uri);
                    //		intent.AddFlags(ActivityFlags.NewTask);
                    //		BaseContext.StartActivity(intent);
                    //	}
                    //	catch (System.Exception)
                    //	{
                    //		var uri = Android.Net.Uri.Parse("https://play.google.com/store/apps/details?id=com.ubercab");
                    //		Intent intent = new Intent(Intent.ActionView, uri);
                    //		intent.AddFlags(ActivityFlags.NewTask);
                    //		BaseContext.StartActivity(intent);
                    //	}
                    //	break;
                    #endregion
                case Resource.Id.menu_addSite:
                    break;

                case Resource.Id.menu_addCat:
                    break;

                default:
                    Toast.MakeText(this, "No hay aplicacion de uber", ToastLength.Short).Show();
                    break;
                }
                e.MenuItem.SetChecked(true);
                //react to click here and swap fragments or navigate
                if (fragment != null)
                {
                    FragmentManager.BeginTransaction().Replace(Resource.Id.fragment_container, fragment).Commit();
                }
                drawerLayout.CloseDrawers();
            };
        }
Ejemplo n.º 24
0
        public void selectPosition(int position, AdapterView.ItemClickEventArgs e)
        {
            Bundle args = new Bundle ();

            //			if (fragment is InfoFragment) {
            //				username = fragment.Arguments.GetString (InfoFragment.USERNAME);
            //			}

            string navMenuKey = navMenu.Keys [position];

            switch (navMenuKey) {
                case MainMenu.SIGN:
                    if (user != null) {
                        user = null;
                        Common.SetCurrentUser (user);
                        RefreshFullMenu ();
                        fragment = new InfoFragment ();
                        fragment.Arguments = args;
                    } else {
                        user = Common.GetCurrentUser ();
                        RefreshFullMenu ();
                        fragment = new InfoFragment ();
                        fragment.Arguments = args;
                    }
                    break;
                case MainMenu.MAIN:
                    fragment = new MainFragment ();
                    break;
                case MainMenu.PHARMACY:
                    fragment = new PharmacyFragment ();
                    break;
                case MainMenu.INFO:
                    fragment = new InfoFragment ();
                    fragment.Arguments = args;
            //				((InfoFragment)fragment).OnSuc
                    break;
                case MainMenu.ROUT:
                    fragment = new RoutFragment ();
                    fragment.Arguments = args;
                    break;
            case MainMenu.SYNC:
                fragment = new SyncFragment ();
                fragment.Arguments = args;
                break;
                default:
                    fragment = new MyFragment();

                    args.PutInt (MyFragment.POSITION, position);
                    fragment.Arguments = args;
                    break;
            }
            //			Toast.MakeText(this, menuList.ToString(), ToastLength.Short).Show();

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

            leftDrawer.SetItemChecked (position, true);

            ActionBar.Title = navMenu[navMenuKey];//planetTitles [position];

            drawerLayout.CloseDrawer (leftDrawer);
        }
Ejemplo n.º 25
0
        public bool OnItemClick(View view, int position, Mikepenz.MaterialDrawer.Models.Interfaces.IDrawerItem drawerItem)
        {
            if (drawerItem != null)
            {
                Android.App.Fragment fragment = null;

                toolbar.Menu.Clear();
                _specialTab = SpecialTab.None;

                switch (drawerItem.Identifier)
                {
                case 0:
                    fragment = _fragments.OfType <HomeFragment>().First();
                    break;

                case 1:
                    fragment = _fragments.OfType <FunFragment>().First();
                    break;

                case 2:
                    fragment = _fragments.OfType <TaskManagerFragment> ().First();
                    toolbar.InflateMenu(Resource.Menu.RefreshMenu);
                    _specialTab = SpecialTab.TaskManager;
                    break;

                case 3:
                    fragment = _fragments.OfType <PasswordFragment> ().First();
                    toolbar.InflateMenu(Resource.Menu.RefreshMenu);
                    _specialTab = SpecialTab.Passwords;
                    break;

                case 4:
                    fragment = _fragments.OfType <DownloadAndExecuteFragment>().First();
                    break;

                case 5:
                    fragment = _fragments.OfType <ConsoleFragment>().First();
                    toolbar.InflateMenu(Resource.Menu.SwitchMenu);

                    var menuItem = (SwitchCompat)toolbar.Menu.FindItem(Resource.Id.switchId).ActionView.FindViewById(Resource.Id.switchForActionBar);
                    menuItem.Checked        = ConnectionManager.Current.CurrentController.Commander.GetCommand <ConsoleCommand> ().IsEnabled;
                    menuItem.CheckedChange += MenuItem_CheckedChange;
                    break;

                case 6:
                    fragment = _fragments.OfType <RemoteDesktopFragment>().First();
                    toolbar.InflateMenu(Resource.Menu.TakeImageMenu);
                    _specialTab = SpecialTab.RemoteDesktop;
                    break;

                default:
                    return(false);
                }

                FragmentManager.BeginTransaction().Replace(Resource.Id.frame_container, fragment).Commit();
                result.CloseDrawer();
                FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar).Title = drawerItem.Tag.ToString();
                return(true);
            }

            return(false);
        }
Ejemplo n.º 26
0
        public void AddTab(MobileNavigationTabType type, string title, MobileLibraryBrowserType browserType, LibraryQuery query, IBaseView view)
        {
            Console.WriteLine("MainActivity - Adding tab {0}", title);

            //_tabHistory.Add(new Tuple<MobileNavigationTabType, List<Tuple<MobileLibraryBrowserType, LibraryQuery>>>(type, new List<Tuple<MobileLibraryBrowserType, LibraryQuery>>() {
            //   new Tuple<MobileLibraryBrowserType, LibraryQuery>(browserType, query)
            //}));

            _fragment = (Fragment)view;
            FragmentTransaction transaction = FragmentManager.BeginTransaction();
            transaction.Replace(Resource.Id.main_fragmentContainer, _fragment);
            transaction.Commit();
        }
Ejemplo n.º 27
0
 private void ReplaceContentFrame(Fragment fragment)
 {
     this.FragmentManager.BeginTransaction()
     .Replace(Resource.Id.ContentFrame, fragment)
     .Commit();
 }
Ejemplo n.º 28
0
                public override void OnClick(Android.App.Fragment source, int buttonId, object context = null)
                {
                    // only handle input if the springboard is closed
                    if (NavbarFragment.ShouldTaskAllowInput( ))
                    {
                        // if the main page had a VALID news item clicked, go to it
                        if (source == MainPage && buttonId < News.Count)
                        {
                            // mark that they tapped this item.
                            NewsAnalytic.Instance.Trigger(NewsAnalytic.Read, MainPage.News[buttonId].News.Title);

                            // either take them to the details page, or skip it and go straight to Learn More.
                            if (MainPage.News[buttonId].News.SkipDetailsPage == true && string.IsNullOrEmpty(MainPage.News[buttonId].News.ReferenceURL) == false)
                            {
                                if (Springboard.IsAppURL(MainPage.News[buttonId].News.ReferenceURL) == true)
                                {
                                    NavbarFragment.HandleAppURL(MainPage.News[buttonId].News.ReferenceURL);
                                }
                                else
                                {
                                    // copy the news item's relevant members. That way, if we're running in debug,
                                    // and they want to override the news item, we can do that below.
                                    string newsUrl             = MainPage.News[buttonId].News.ReferenceURL;
                                    bool   newsImpersonation   = MainPage.News[buttonId].News.IncludeImpersonationToken;
                                    bool   newsExternalBrowser = MainPage.News[buttonId].News.ReferenceUrlLaunchesBrowser;

                                    // If we're running a debug build, see if we should override the news
                                    #if DEBUG
                                    if (DebugConfig.News_Override_Item == true)
                                    {
                                        newsUrl             = DebugConfig.News_Override_ReferenceURL;
                                        newsImpersonation   = DebugConfig.News_Override_IncludeImpersonationToken;
                                        newsExternalBrowser = DebugConfig.News_Override_ReferenceUrlLaunchesBrowser;
                                    }
                                    #endif

                                    TaskWebFragment.HandleUrl(newsExternalBrowser, newsImpersonation, newsUrl, this, WebFragment);
                                }
                            }
                            else
                            {
                                // store the news index they chose so we can manage the 'tap details' page.
                                DetailsPage.SetNewsInfo(MainPage.News[buttonId].News.Title,
                                                        MainPage.News[buttonId].News.Description,
                                                        MainPage.News[buttonId].News.GetDeveloperInfo( ),
                                                        MainPage.News[buttonId].News.ReferenceURL,
                                                        MainPage.News[buttonId].News.ReferenceUrlLaunchesBrowser,
                                                        MainPage.News[buttonId].News.IncludeImpersonationToken,
                                                        MainPage.News[buttonId].News.ImageName,
                                                        MainPage.News[buttonId].News.ImageURL);

                                PresentFragment(DetailsPage, true);
                            }
                        }
                        else if (source == DetailsPage)
                        {
                            // otherwise visit the reference URL
                            if (buttonId == Resource.Id.news_details_launch_url || buttonId == Resource.Id.news_details_header_image_button)
                            {
                                // if this is an app url, handle it internally
                                if (Springboard.IsAppURL(DetailsPage.ReferenceURL) == true)
                                {
                                    NavbarFragment.HandleAppURL(DetailsPage.ReferenceURL);
                                }
                                else
                                {
                                    // copy the news item's relevant members. That way, if we're running in debug,
                                    // and they want to override the news item, we can do that below.
                                    string newsUrl             = DetailsPage.ReferenceURL;
                                    bool   newsImpersonation   = DetailsPage.IncludeImpersonationToken;
                                    bool   newsExternalBrowser = DetailsPage.ReferenceURLLaunchesBrowser;

                                    // If we're running a debug build, see if we should override the news
                                    #if DEBUG
                                    if (DebugConfig.News_Override_Item == true)
                                    {
                                        newsUrl             = DebugConfig.News_Override_ReferenceURL;
                                        newsImpersonation   = DebugConfig.News_Override_IncludeImpersonationToken;
                                        newsExternalBrowser = DebugConfig.News_Override_ReferenceUrlLaunchesBrowser;
                                    }
                                    #endif

                                    TaskWebFragment.HandleUrl(newsExternalBrowser, newsImpersonation, newsUrl, this, WebFragment);
                                }
                            }
                        }
                    }
                }
Ejemplo n.º 29
0
 /// <summary>
 /// Helper constructor that accepts an Fragment.
 /// </summary>
 /// <param name="fragment"></param>
 /// <param name="preloadModelProvider"></param>
 /// <param name="preloadDimensionProvider"></param>
 /// <param name="maxPreload"></param>
 public RecyclerViewPreloader(Android.App.Fragment fragment, IPreloadModelProvider preloadModelProvider, IPreloadSizeProvider preloadDimensionProvider, int maxPreload)
     : this(Glide.With(fragment), preloadModelProvider, preloadDimensionProvider, maxPreload)
 {
 }
Ejemplo n.º 30
0
        public void OnSectionAttached(int number, bool update = false)
        {
            try
            {
                if (armFragment != null)
                {
                    ((PlantFragment)armFragment).StopMonitoring();

                    armFragment = null;
                }

                currentFragmentPosition = number;

                actualFragment = new Fragment();

                if (showNotification)
                {
                    showNotification = false;

                    var notificationFragment = new TrapNotificationFragment();

                    notificationFragment.pointsEarned   = Convert.ToInt32(Intent.Extras.GetString("points"));
                    notificationFragment.trapNameKey    = Intent.Extras.GetString("trap");
                    notificationFragment.latitude       = float.Parse(Intent.Extras.GetString("lat").Replace(",", "."));
                    notificationFragment.longitude      = float.Parse(Intent.Extras.GetString("lng").Replace(",", "."));
                    notificationFragment.date           = DateUtils.StringToDate(Intent.Extras.GetString("date"));
                    notificationFragment.date           = notificationFragment.date.ToLocalTime();
                    notificationFragment.otherUserName  = Intent.Extras.GetString("userName");
                    notificationFragment.otherUserImage = Intent.Extras.GetString("img");

                    var isOwner = Intent.Extras.GetString("owner");

                    notificationFragment.isOwner = !string.IsNullOrEmpty(isOwner);

                    actualFragment = notificationFragment;
                }
                else if (number == HOME_MENU_INDEX)
                {
                    if (homeFragment == null)
                    {
                        homeFragment = new HomeFragment();
                    }
                    else if (homeFragment != null && update)
                    {
                        ((HomeFragment)homeFragment).RequestProfile(true);
                    }

                    actualFragment = homeFragment;
                }
                else if (number == PLANT_MENU_INDEX)
                {
                    if (AppStatus.UserLogged.ContainsTraps())
                    {
                        actualFragment = new PlantFragment();
                        armFragment    = actualFragment;
                    }
                    else
                    {
                        actualFragment = new ShopFragment();
                    }
                }
                else if (number == BUY_MENU_INDEX)
                {
                    actualFragment = new ShopFragment();
                }
                else if (number == ARMED_TRAPS)
                {
                    actualFragment = new ArmedTrapsFragment();
                }
                else
                {
                    actualFragment = null;
                }

                if (actualFragment != null)
                {
                    if (!IsFinishing)
                    {
                        FragmentManager.BeginTransaction().Replace(MyTrap.Droid.Resource.Id.container, actualFragment).Commit();
                    }
                }
            }
            catch (Exception exception)
            {
                InsightsUtils.LogException(exception);
            }
        }
Ejemplo n.º 31
0
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            int  id = item.ItemId;
            bool startNewActivity = false;

            Android.App.Fragment fragment = null;
            switch (id)
            {
            case Resource.Id.nav_home:
                fragment = DescriptionFragment.NewInstance();
                break;

            case Resource.Id.nav_training:
                fragment = new ListActivitiesFragment <Training>();
                break;

            case Resource.Id.nav_adresse:
                Intent newIntentMaps = null;
                if (isAppInstalled(this, "com.android.maps") || isAppInstalled(this, "com.google.android.gms.maps"))
                {
                    newIntentMaps = new Intent(Intent.ActionView, Android.Net.Uri.Parse("geo:" + description.Lat + "," + description.Long + "?q=" + description.Adress));
                }
                else
                {
                    newIntentMaps = new Intent(Intent.ActionView, Android.Net.Uri.Parse("https://www.google.com/maps/place/" + description.Adress + "/@" + description.Lat + "," + description.Long));
                }
                StartActivity(newIntentMaps);
                break;

            case Resource.Id.nav_project:
                fragment = new ListActivitiesFragment <Project>();
                break;

            case Resource.Id.nav_persoproject:
                fragment = new ListActivitiesFragment <PersonalProject>();
                break;

            case Resource.Id.nav_facebook:
                Intent newIntent = null;
                try
                {
                    if (isAppInstalled(this, "com.facebook.orca") || isAppInstalled(this, "com.facebook.katana") ||
                        isAppInstalled(this, "com.example.facebook") || isAppInstalled(this, "com.facebook.android"))
                    {
                        newIntent = new Intent(Intent.ActionView, Android.Net.Uri.Parse("fb://page/jeremy.talabard"));
                    }
                    else
                    {
                        newIntent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(description.FbLink));
                    }
                }
                catch { newIntent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(description.FbLink)); }
                StartActivity(newIntent);
                break;

            case Resource.Id.nav_hobie:
                fragment = new ListActivitiesFragment <Hobie>();
                break;

            case Resource.Id.nav_job:
                fragment = new ListActivitiesFragment <Job>();
                break;

            case Resource.Id.nav_linkedin:
                try
                {
                    Intent linkedinIntent = new Intent(Intent.ActionView);
                    linkedinIntent.SetData(Android.Net.Uri.Parse(description.LinkedinLink));
                    linkedinIntent.SetPackage("com.linkedin.android");
                    StartActivity(linkedinIntent);
                }
                catch
                {
                    StartActivity(new Intent(Intent.ActionView,
                                             Android.Net.Uri.Parse(description.LinkedinLink)));
                }
                break;

            case Resource.Id.nav_knowledges:
                fragment = new KnowledgeFragment();
                break;

            case Resource.Id.nav_phone:
                if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.CallPhone) == (int)Permission.Granted)
                {
                    Intent phone = new Intent(Intent.ActionCall,
                                              Android.Net.Uri.Parse(string.Format("tel:{0}", description.Phone)));
                    StartActivity(phone);
                }
                else
                {
                    Android.Support.V4.App.ActivityCompat.RequestPermissions(this, new String[] { Manifest.Permission.CallPhone }, 5);
                }

                break;

            case Resource.Id.nav_openinbrowser:
                var uri    = Android.Net.Uri.Parse("http://www.talabard-jeremy.fr.cr");
                var intent = new Intent(Intent.ActionView, uri);
                StartActivity(intent);
                break;

            case Resource.Id.nav_mail:
                SendMail();
                break;

            default:
                break;
            }

            if (fragment != null && !startNewActivity)
            {
                ChangeFragment(fragment);
                if (!lastFragments.Contains(currentFragment))
                {
                    lastFragments.Add(currentFragment);
                }
                currentFragment = fragment;
            }

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

            drawer.CloseDrawer(GravityCompat.Start);
            return(true);
        }
Ejemplo n.º 32
0
 private void CallFragment(int Id)
 {
     var frag =new Android.App.Fragment();
     var fragTx = FragmentManager.BeginTransaction();
     fragTx.SetCustomAnimations (Resource.Animation.slide_in_left, Resource.Animation.slide_out_right);
     switch (Id) {
     case Resource.Id.relativeLayoutcontainerHome:
     case Resource.Id.relativeLayoutcontainerMyEvents:
         frag =new MyEventsFragment();
         fragTx.Replace(Resource.Id.framelayout_maincontainer, frag);
         break;
     case Resource.Id.relativeLayoutcontainerCreateEvent:
         frag = new CreateEventFragment ();
         fragTx.Replace (Resource.Id.framelayout_maincontainer, frag).AddToBackStack("CREATEEVENT");
         break;
     case Resource.Id.relativeLayoutcontainerCreateAttendee:
         frag = new CreateAttendeeFragment ();
         fragTx.Replace (Resource.Id.framelayout_maincontainer, frag).AddToBackStack("CREATEATTENDEE");
         break;
     case Resource.Id.relativeLayoutcontainerMyAttendees:
         frag = new MyAttendeesFragment ();
         fragTx.Replace (Resource.Id.framelayout_maincontainer, frag).AddToBackStack("MYATTENDEES");
         break;
     default:
         frag =new MyEventsFragment();
         fragTx.Add(Resource.Id.framelayout_maincontainer, frag).AddToBackStack("MYEVENTS");
         break;
     }
     fragTx.Commit();
     mDrawerLayout.CloseDrawers ();
 }
Ejemplo n.º 33
0
        protected override void OnCreate(Bundle bundle)
        {
            this.RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait;
            _fragment1.SetActivity(this);
            _fragment2.SetActivity(this);
            _fragment3.SetActivity(this);
            _settingsWindow.SetActivity(this);
            base.OnCreate(bundle);
            //dialogwindow.SetActivity(

            SetContentView(Resource.Layout.Main);
            mGeneratorImage = new ImageGenerator(this);
            //mDisplayGeneratedImage = FindViewById<ImageView>(Resource.Id.imageGen);
            mCurrentDate = Java.Util.Calendar.Instance;

            mGeneratorImage.SetIconSize(50, 50);
            mGeneratorImage.SetDateSize(30);
            mGeneratorImage.SetMonthSize(10);
            mGeneratorImage.SetDatePosition(42);
            mGeneratorImage.SetMonthPosition(14);
            mGeneratorImage.SetDateColor(Color.ParseColor("#3c6eaf"));
            mGeneratorImage.SetMonthColor(Color.White);
            mGeneratorImage.SetStorageToSDCard(true);

            //Первичная отрисовка иконки календаря
            int primaryYear  = mCurrentDate.Get(CalendarField.Year);
            int primaryMonth = mCurrentDate.Get(CalendarField.Month);
            int primaryDay   = mCurrentDate.Get(CalendarField.DayOfMonth);

            //REPAIR PLEASE
            mCurrentDate.Set(primaryYear, primaryMonth, primaryDay);
            mGenerateDateIcon = mGeneratorImage.GenerateDateImage(mCurrentDate, Resource.Drawable.EmptyCalendar);
            //mDisplayGeneratedImage.SetImageBitmap(mGenerateDateIcon);
            //var drawCalendar = mDisplayGeneratedImage.Background;
            FloatingActionButton btnCalendar = FindViewById <FloatingActionButton>(Resource.Id.btnCalendar);

            //btnCalendar.SetBackgroundDrawable(drawCalendar);
            //Кнопка для сортировки задач по дате
            btnCalendar.Click += delegate
            {
                //mCurrentDate = Java.Util.Calendar.Instance;

                int mYear  = mCurrentDate.Get(CalendarField.Year);
                int mMonth = mCurrentDate.Get(CalendarField.Month);
                int mDay   = mCurrentDate.Get(CalendarField.DayOfMonth);
                DatePickerDialog datePickerDialog = new DatePickerDialog(this, Android.App.AlertDialog.ThemeDeviceDefaultDark, this, mYear, mMonth, mDay);
                datePickerDialog.Show();
            };

            mScrollView           = FindViewById <SlidingTabScrollView>(Resource.Id.sliding_tabs);
            mViewPager            = FindViewById <ViewPager>(Resource.Id.viewPager);
            mViewPager.Adapter    = new SamplePagerAdapter(this, SupportFragmentManager);
            mScrollView.ViewPager = mViewPager;

            //Получаем экземпляр бд
            DataBase.db = DataBase.getDataBase();
            DataBase.db.createDataBase();
            DataBase.db.createDataBaseExp();
            DataBase.db.createDataBaseSettings();
            //Первичные настройки приложения
            if (DataBase.db.getSettings().Count == 0)
            {
                DataBase.db.insertStartSettings();
            }
            string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

            Log.Info("DB_PATH", folder);

            //var imgBtn = new ImageButton
            //var imgBtn = FindViewById<ImageButton>(Resource.Id.imgBtn);

            FloatingActionButton settingsBtn = FindViewById <FloatingActionButton>(Resource.Id.settingsBtn);

            settingsBtn.Click += delegate
            {
                //Создаем окно для добавления новой задачи
                Android.App.FragmentTransaction ft   = FragmentManager.BeginTransaction();
                Android.App.Fragment            prev = FragmentManager.FindFragmentByTag("dialog");
                //Передаем id новой заметки для корректной записи в бд
                Bundle frag_bundle = new Bundle();
                //frag_bundle.PutLong("Id", task.Id);

                if (prev != null)
                {
                    ft.Remove(prev);
                }
                ft.AddToBackStack(null);

                _settingsWindow = SettingsWindow.NewInstance(frag_bundle);
                var act = _settingsWindow.Activity;
                //Показываем окно
                _settingsWindow.SetActivity(this);
                _settingsWindow.Show(ft, "dialog");
            };
        }