Пример #1
0
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            if (requestCode == PERMISSION_ReadExternalStorage)
            {
                if (grantResults[0] == Permission.Granted)
                {
                    Songleton.Instance.AllSongs = MusicRetrieval.LoadSongs(this);
                    SongListFragment songListFragment = new SongListFragment();
                    //MusicControlFragment musicControlFragment = new MusicControlFragment ();
                    MusicControls musicControls = new MusicControls();
                    //var trans = FragmentManager.BeginTransaction ();以下两条语句极度重要,解决大问题!
                    Android.Support.V4.App.FragmentManager     fragmentManager = SupportFragmentManager;
                    Android.Support.V4.App.FragmentTransaction trans           = fragmentManager.BeginTransaction();
                    trans.Add(Resource.Id.fragment_container, songListFragment, "songListFragment");
                    trans.Add(Resource.Id.music_controls_container, musicControls, "musicControls");
                    trans.Commit();

                    if (Build.VERSION.SdkInt != Android.OS.BuildVersionCodes.NMr1)
                    {
                        Toast.MakeText(this, "读取数据权限已申请", ToastLength.Short).Show();
                    }
                }
                else
                {
                    if (Build.VERSION.SdkInt != Android.OS.BuildVersionCodes.NMr1)
                    {
                        Toast.MakeText(this, "申请读取数据权限被拒", ToastLength.Short).Show();
                    }
                }
            }
        }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            //java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/audio/media from pid=17271, uid=10085 requires android.permission.READ_EXTERNAL_STORAGE
            //6.0及以上需要动态申请权限
            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.M)
            {
                //RequestWriteSettings();
                bool isGrant = ActivityCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage) == Permission.Granted;
                if (isGrant == false)
                {
                    ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.ReadExternalStorage }, PERMISSION_ReadExternalStorage);
                }
                else
                {
                    Songleton.Instance.AllSongs = MusicRetrieval.LoadSongs(this);
                    if (savedInstanceState == null)
                    {
                        SongListFragment songListFragment = new SongListFragment();
                        //MusicControlFragment musicControlFragment = new MusicControlFragment ();
                        MusicControls musicControls = new MusicControls();
                        //var trans = FragmentManager.BeginTransaction ();以下两条语句极度重要,解决大问题!
                        Android.Support.V4.App.FragmentManager     fragmentManager = SupportFragmentManager;
                        Android.Support.V4.App.FragmentTransaction trans           = fragmentManager.BeginTransaction();
                        trans.Add(Resource.Id.fragment_container, songListFragment, "songListFragment");
                        trans.Add(Resource.Id.music_controls_container, musicControls, "musicControls");
                        trans.Commit();
                    }
                    //在程序中获取string.xml中字符串和数值
                    Toast.MakeText(this, this.Resources.GetString(Resource.String.scan_songs) + Songleton.Instance.AllSongs.Count.ToString(), ToastLength.Short).Show();
                }
            }
        }
Пример #3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            mapGraph = MainApp.Instance.MainBuildingGraph.Value;

            view = inflater.Inflate(Resource.Layout.fragment_mainbuilding, container, false);

            fragments = new List <MainBuildingMapFragment>()
            {
                new MainBuildingMapFragment(Resource.Drawable.first_floor), new MainBuildingMapFragment(Resource.Drawable.second_floor), new MainBuildingMapFragment(Resource.Drawable.third_floor)
            };

            fragmentTransaction = Activity.SupportFragmentManager.BeginTransaction();
            fragmentTransaction.Add(Resource.Id.frame_mainbuilding, fragments[2], "MAP_MAINBUILDING_3");
            fragmentTransaction.Add(Resource.Id.frame_mainbuilding, fragments[1], "MAP_MAINBUILDING_2");
            fragmentTransaction.Detach(fragments[2]);
            fragmentTransaction.Detach(fragments[1]);
            fragmentTransaction.Add(Resource.Id.frame_mainbuilding, fragments[0], "MAP_MAINBUILDING_1");
            fragmentTransaction.Commit();

            var array = MainApp.Instance.RoomsDictionary.Select(x => x.Key).ToArray();

            editTextInputFrom              = view.FindViewById <AutoCompleteTextView>(Resource.Id.autoCompleteTextView_from);
            editTextInputFrom.FocusChange += EditTextFromFocusChanged;
            editTextInputFrom.Adapter      = new ArrayAdapter(Activity.BaseContext, Android.Resource.Layout.SimpleDropDownItem1Line, array);
            editTextInputFrom.AddTextChangedListener(this);

            editTextInputTo = view.FindViewById <AutoCompleteTextView>(Resource.Id.autoCompleteTextView_to);
            editTextInputTo.SetOnEditorActionListener(this);
            editTextInputTo.FocusChange += EditTextToFocusChanged;
            editTextInputTo.Adapter      = new ArrayAdapter(Activity.BaseContext, Android.Resource.Layout.SimpleDropDownItem1Line, array);
            editTextInputTo.AddTextChangedListener(this);

            appBar = view.FindViewById <AppBarLayout>(Resource.Id.appbar_mainbuilding);
            appBar.AddOnOffsetChangedListener(this);

            fab        = view.FindViewById <FloatingActionButton>(Resource.Id.fab_mainbuilding);
            fab.Click += Fab_Click;

            relativeLayout       = view.FindViewById <RelativeLayout>(Resource.Id.search_frame_mainbuilding);
            relativeLayoutParams = (AppBarLayout.LayoutParams)relativeLayout.LayoutParameters;

            frameLayout     = view.FindViewById <FrameLayout>(Resource.Id.frame_mainbuilding);
            fabLayoutParams = (CoordinatorLayout.LayoutParams)fab.LayoutParameters;

            var rl = view.FindViewById <RelativeLayout>(Resource.Id.relativelayout_floor_buttons_mainbuilding);

            rl.BringToFront();

            buttonUp        = view.FindViewById <FloatingActionButton>(Resource.Id.fab_up_mainbuilding);
            buttonUp.Click += ButtonUp_Click;
            buttonUp.Alpha  = 0.7f;

            buttonDown         = view.FindViewById <FloatingActionButton>(Resource.Id.fab_down_mainbuilding);
            buttonDown.Click  += ButtonDown_Click;
            buttonDown.Alpha   = 0.7f;
            buttonDown.Enabled = false;

            return(view);
        }
Пример #4
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            MyView myholder = holder as MyView;

            myholder.Task.Text          = Mitems[position].task_name;
            myholder.Create_by.Text     = Mitems[position].task_created_by;
            myholder.Deadline_date.Text = Mitems[position].deadlineDate.ToString();
            // myholder.time_left.Text = Mitems[position].mark_to;
            var local = new LocalOnClickListener();

            myholder.Linear.SetOnClickListener(local);
            local.HandleOnClick = () =>
            {
                string id = Mitems[position].task_id;

                ComplainceFrag nextFrag = new ComplainceFrag();
                Android.Support.V4.App.FragmentTransaction ft = fragment.BeginTransaction();
                //ft.Replace(Resource.Id.container, nextFrag, "ComplainceFragment");
                ft.Hide(fragment.FindFragmentByTag("MainFrag"));
                ft.Add(Resource.Id.container, nextFrag, "ComplainceFragment");
                ft.AddToBackStack("TaskInboxFrag");
                ft.SetTransition(FragmentTransaction.TransitFragmentOpen);
                ft.Commit();
                // fragment.BeginTransaction().Replace(Resource.Id.container, nextFrag).Commit();
                Bundle bundle = new Bundle();
                bundle.PutString("task_id", id);
                nextFrag.Arguments = bundle;
            };


            myholder.time_left.Text = date_difference(DateTime.Now, Mitems[position].deadlineDate);
        }
        public void OnTabChanged(string tabId)
        {
            TabInfo newTab = this.mapTabInfo[tabId];

            newTab.args.PutString("ProcessID", ProcessID);
            //if (mLastTab != newTab)
            //{
            Android.Support.V4.App.FragmentTransaction ft = this.SupportFragmentManager.BeginTransaction();
            if (mLastTab != null)
            {
                if (mLastTab.fragment != null)
                {
                    ft.Detach(mLastTab.fragment);
                }
            }
            if (newTab != null)
            {
                if (newTab.fragment == null)
                {
                    newTab.fragment = Android.Support.V4.App.Fragment.Instantiate(this, Java.Lang.Class.FromType(newTab.clss).Name
                                                                                  , newTab.args);

                    ft.Add(Resource.Id.realtabcontent, newTab.fragment, newTab.tag);
                }
                else
                {
                    ft.Attach(newTab.fragment);
                }
            }

            mLastTab = newTab;
            ft.Commit();
            this.SupportFragmentManager.ExecutePendingTransactions();
            //}
        }
Пример #6
0
        public virtual void ShowAllowingStateLoss(FragmentManager manager, string tag)
        {
            FragmentTransaction ft = manager.BeginTransaction();

            ft.Add(this, tag);
            ft.CommitAllowingStateLoss();
        }
Пример #7
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

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

			ArrayAdapter<string> ad = new ArrayAdapter<string> (ActionBar.ThemedContext, Android.Resource.Layout.SimpleListItem1, listContent);
			DrawerLayout drawer = FindViewById<DrawerLayout> (Resource.Id.drawer_layout);
			ListView list = FindViewById<ListView> (Resource.Id.drawer);
			list.SetAdapter (ad);

			transaction = SupportFragmentManager.BeginTransaction ();
			transaction.Add (Resource.Id.main,fragments [0]);
			transaction.Commit ();

			list.ItemClick += (sender, e) => {
				var item = sender as ListView;
				var position = item.CheckedItemPosition;
				transaction = SupportFragmentManager.BeginTransaction();
				transaction.Replace(Resource.Id.main,fragments[position]);
				transaction.Commit();
				drawer.CloseDrawer(item);
			};
		}
Пример #8
0
 private void NavigateToFragment(SupportFragment fragment, string tag)
 {
     fragmentTransaction = SupportFragmentManager.BeginTransaction();
     fragmentTransaction.Add(Resource.Id.fragmentContainer, fragment, tag);
     fragmentTransaction.Replace(Resource.Id.fragmentContainer, fragment, tag);
     fragmentTransaction.AddToBackStack(null);
     fragmentTransaction.Commit();
 }
Пример #9
0
        void InitMap()
        {
            _mapFragment = new MainMapFragment().Init(FindViewById <ViewGroup>(stops.Resource.Id.mapCointatiner));


            Android.Support.V4.App.FragmentTransaction transaction = SupportFragmentManager.BeginTransaction();
            transaction.SetTransition(Android.Support.V4.App.FragmentTransaction.TransitFragmentFade);
            transaction.Add(stops.Resource.Id.mapCointatiner, _mapFragment);
            transaction.Commit();
        }
Пример #10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            if (SupportFragmentManager.FindFragmentByTag(FRAGTAG) == null)
            {
                Android.Support.V4.App.FragmentTransaction transaction = SupportFragmentManager.BeginTransaction();
                var fragment = new AdvancedImmersiveModeFragment();
                transaction.Add(fragment, FRAGTAG);
                transaction.Commit();
            }
        }
Пример #11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            v4App.FragmentTransaction ft       = SupportFragmentManager.BeginTransaction();
            v4App.Fragment            fragment = new JournalCreateView();

            ft.Add(Resource.Id.fragment_container, fragment);
            ft.AddToBackStack(null);
            ft.Commit();
        }
Пример #12
0
        public void addITR(TableLayout tl)
        {
            TableRow notes = new TableRow(this.Activity);

            notes.Tag = "notes";
            note      = new EditText(this.Activity);
            note.Hint = "Notes";
            if (DataController.note != "")
            {
                note.Text = DataController.note;
            }
            note.Gravity = GravityFlags.Center;

            TableRow.LayoutParams stretchRow = new TableRow.LayoutParams();
            stretchRow.Span = 6;

            notes.AddView(note, stretchRow);
            tl.AddView(notes);

            TableRow btnRow = new TableRow(this.Activity);

            btnRow.Tag = "btnRow";

            Button requestITR = new Button(this.Activity);

            requestITR.Text   = "ITR";
            requestITR.Click += (object sender, EventArgs e) => {
                if (checkNetwork())
                {
                    Android.Support.V4.App.Fragment residentsFragment = null;
                    residentsFragment = new ResidentsFragment();
                    ((ResidentsFragment)residentsFragment).SetResidentUpdate(residents);
                    ((ResidentsFragment)residentsFragment).SetNotePrev(note.Text);
                    Android.Support.V4.App.FragmentTransaction ft = FragmentManager.BeginTransaction();

                    ft.Add(Resource.Id.content_frame, residentsFragment, "residentsFragment");
                    ft.Hide(FragmentManager.FindFragmentByTag("residentsPrevFragment"));
                    ft.AddToBackStack(null);
                    ft.Commit();
                }
                else
                {
                    showNetworkError();
                }
            };



            btnRow.AddView(requestITR, stretchRow);
            tl.AddView(btnRow);
        }
Пример #13
0
 public void Show(V4FragmentManager manager)
 {
     if (!dismissed || manager.IsDestroyed)
     {
         return;
     }
     dismissed = false;
     new Handler().Post(() => {
         V4FragmentTransaction ft = manager.BeginTransaction();
         ft.Add(this, "actionSheet");
         ft.AddToBackStack(null);
         ft.CommitAllowingStateLoss();
     });
 }
Пример #14
0
        private void InitMapFragment()
        {
            _mapFragment = SupportFragmentManager.FindFragmentByTag("map") as SupportMapFragment;
            if (_mapFragment == null)
            {
                GoogleMapOptions mapOptions = new GoogleMapOptions()
                                              .InvokeMapType(GoogleMap.MapTypeSatellite)
                                              .InvokeZoomControlsEnabled(false)
                                              .InvokeCompassEnabled(true);

                FragmentTransaction fragTx = SupportFragmentManager.BeginTransaction();
                _mapFragment = SupportMapFragment.NewInstance(mapOptions);
                fragTx.Add(Resource.Id.mapWithOverlay, _mapFragment, "map");
                fragTx.Commit();
            }
        }
Пример #15
0
 public static void AddFragment(Context context, Android.Support.V4.App.Fragment newFragment, string TAG)
 {
     Android.Support.V4.App.Fragment            myFragment      = null;
     Android.Support.V4.App.FragmentManager     fragmentManager = ((FragmentActivity)context).SupportFragmentManager;
     Android.Support.V4.App.FragmentTransaction ft = fragmentManager.BeginTransaction();
     myFragment = fragmentManager.FindFragmentByTag(TAG);
     if (myFragment == null)
     {
         ft.Add(Resource.Id.home_frame_layout, newFragment, TAG);
         ft.AddToBackStack(null);
         ft.Commit();
     }
     else
     {
         ft.Detach(myFragment).Attach(myFragment);
         ft.Commit();
     }
 }
Пример #16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.League);

            //Initialize the toolbar
            InitToolbar();

            //Init activity properties
            InitActivityProperties();

            //Initialize properties
            InitProperties();

            //Attach tabbedfragment
            if (savedInstanceState == null)
            {
                var tabModels = new List <TabbedViewPagerModel>();
                tabModels.Add(new TabbedViewPagerModel {
                    FragmentType = FragmentType.LeagueMatches, TabTitle = Resources.GetString(Resource.String.leagueMatches), Data = new MatchesModel {
                        Teams = Teams, Matches = Matches, Leagues = new List <League> {
                            League
                        }
                    }
                });
                tabModels.Add(new TabbedViewPagerModel {
                    FragmentType = FragmentType.LeagueTable, TabTitle = Resources.GetString(Resource.String.leagueTable), Data = Teams
                });
                tabModels.Add(new TabbedViewPagerModel {
                    FragmentType = FragmentType.LeagueStats, TabTitle = Resources.GetString(Resource.String.leagueStats), Data = new LeagueStatModel {
                        Players = Players, Teams = Teams, Stats = PlayerStatistics
                    }
                });

                Android.Support.V4.App.Fragment            fr = TabbedViewPagerFragment.Instance(tabModels);
                Android.Support.V4.App.FragmentTransaction ft = SupportFragmentManager.BeginTransaction();
                ft.Add(Resource.Id.content_frame, fr).Commit();
            }

            FindViewById <TextView>(Resource.Id.leagueName).Text = League.Name;
        }
Пример #17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.MatchActivity);

            //Initilalize toolbar
            InitToolbar();

            //Initialize properties
            InitProperties();

            //Initialize activity properties
            InitActivityProperties();

            //Attach tabbedfragment
            if (savedInstanceState == null)
            {
                var tabModels = new List <TabbedViewPagerModel>();
                tabModels.Add(new TabbedViewPagerModel {
                    FragmentType = FragmentType.Events, TabTitle = Resources.GetString(Resource.String.matchEvents), Data = new MatchEvents {
                        Events = CreateEvents(), Match = Match, HomeTeam = HomeTeam, AwayTeam = AwayTeam
                    }
                });
                tabModels.Add(new TabbedViewPagerModel {
                    FragmentType = FragmentType.MatccPlayers, TabTitle = Resources.GetString(Resource.String.matchPlayers), Data = new MatchPlayersModel {
                        Events = Events, HomeTeam = HomeTeam, AwayTeam = AwayTeam, Match = Match
                    }
                });
                tabModels.Add(new TabbedViewPagerModel {
                    FragmentType = FragmentType.MatchDetail, TabTitle = Resources.GetString(Resource.String.matchDetails), Data = new MatchDetailModel {
                        Match = Match, League = League, Stadium = Stadium
                    }
                });

                Android.Support.V4.App.Fragment            fr = TabbedViewPagerFragment.Instance(tabModels);
                Android.Support.V4.App.FragmentTransaction ft = SupportFragmentManager.BeginTransaction();
                ft.Add(Resource.Id.content_frame, fr).Commit();
            }
        }
Пример #18
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.Leagues);

            //Initilalize toolbar
            InitToolbar();

            //Init properties
            InitProperties();

            //Init activity properties
            InitActivityProperties();

            //Attach tabbedfragment
            if (savedInstanceState == null)
            {
                IEnumerable <League> leagues = UoW.LeagueRepo.GetLeaguesByYear(Year);

                var tabModels = new List <TabbedViewPagerModel>();
                tabModels.Add(new TabbedViewPagerModel {
                    FragmentType = FragmentType.Leagues, TabTitle = Resources.GetString(Resource.String.men), Data = new LeaguesModel {
                        Leagues = leagues.Where(l => l.Gender == GenderEnum.Men).ToList()
                    }
                });
                tabModels.Add(new TabbedViewPagerModel {
                    FragmentType = FragmentType.Leagues, TabTitle = Resources.GetString(Resource.String.women), Data = new LeaguesModel {
                        Leagues = leagues.Where(l => l.Gender == GenderEnum.Women).ToList()
                    }
                });

                Android.Support.V4.App.Fragment            fr = TabbedViewPagerFragment.Instance(tabModels);
                Android.Support.V4.App.FragmentTransaction ft = SupportFragmentManager.BeginTransaction();
                ft.Add(Resource.Id.content_frame, fr).Commit();
            }
        }
Пример #19
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.ActivityMain);
            Android.Support.V4.App.FragmentManager fm = SupportFragmentManager;
            playFragment = (PlayFragment)fm.FindFragmentById(Resource.Layout.FragmentPlay);
            if (playFragment == null)
            {
                playFragment = new PlayFragment();
                Android.Support.V4.App.FragmentTransaction ft = fm.BeginTransaction();
                ft.Add(Resource.Id.main_container, playFragment);
                ft.Commit();
            }
            toolbarFragment = (ToolBarFragment)fm.FindFragmentById(Resource.Layout.FragmentToolBar);
            if (toolbarFragment == null)
            {
                toolbarFragment = new ToolBarFragment();
                Android.Support.V4.App.FragmentTransaction ft = fm.BeginTransaction();
                ft.Add(Resource.Id.toolbar_container, toolbarFragment);
                ft.Commit();
            }

            chordRecognizer = new ChordRecognizer();

            MIDIStyle midiStyle = new MIDIStyle();

            midiStyle.LoadStyle("ddd");
            mplayer                       = new MIDIPlayer(/*this,*/ midiStyle);
            mplayer.OnTactEvent          += (object sender, OnTactEventArgs e) => playFragment.SetTempoAndTact(e.CurrentTempo, e.CurrentTact);
            mplayer.OnChordChangeEvent   += () => OnChordChanged();
            mplayer.OnSectionChangeEvent += () => OnSectionChanged();

            mplayer.Tracks = midiStyle.MidiSection.Tracks;
            mplayer.Start();
        }
Пример #20
0
        private void RenderTrackItTabFragment(FragmentTransaction transaction)
        {
            if (_isMapView)
            {
                if (_fightitFragment != null)
                {
                    transaction.Hide(_fightitFragment);
                }

                InitMapFragment();
                transaction.Show(_mapFragment);
                SetupMapIfNeeded();
            }
            else
            {
                if (_mapFragment != null)
                {
                    transaction.Hide(_mapFragment);
                }

                if (_fightitFragment == null)
                {
                    _fightitFragment = new FightItFragment();
                    transaction.Add(Resource.Id.fragmentContainer, _fightitFragment, "fight");
                }
                else
                {
                    transaction.Show(_fightitFragment);
                }
            }

            if (_listToggleButton != null)
            {
                _listToggleButton.Text = _isMapView ? "List" : "Map";
                _listToggleButton.Visibility = ViewStates.Visible;
            }
        }
Пример #21
0
        public void OnTabSelected(SherlockActionBar.Tab tab, FragmentTransaction transaction)
        {
            DebugHelper.WriteDebugEntry("In IntroActivity OnTabSelected(): " + tab.Tag);
            _currentTabTag = (String)tab.Tag;

            switch (_currentTabTag)
            {


                case "track":
                    RenderTrackItTabFragment(transaction);
                    break;

                case "report":
                    if (_reportFragment == null)
                    {
                        _reportFragment = new ReportCrueltyFragment();
                        transaction.Add(Resource.Id.fragmentContainer, _reportFragment, "report");
                    }
                    else
                    {
                        transaction.Show(_reportFragment);
                    }

                    if (_listToggleButton != null)
                    {
                        _listToggleButton.Visibility = ViewStates.Gone;
                    }

                    break;
            }

        }
        private void SelectLibrary(Library library)
        {
            if (IsFinishing)
            {
                return;
            }

            App.STATE.CurrentLibrary = library;
            string tag = Enum.GetName(typeof(Library), library);

            FragmentTransaction transaction = SupportFragmentManager.BeginTransaction();

            transaction.SetTransition((int)FragmentTransit.FragmentFade);
            Fragment fragment = SupportFragmentManager.FindFragmentByTag(tag);

            if (App.STATE.CanTranslate())
            {
                if (fragment == null)
                {
                    if (App.STATE.CurrentLibrary == Library.DailyText)
                    {
                        string date = App.FUNCTIONS.FormatDateTime(DateTime.Now);

                        fragment = new ArticleFragment(NavStruct.Parse(date), library);
                        fragment.RetainInstance = true;
                    }
                    //else if (App.STATE.CurrentLibrary == Library.Insight)
                    //{
                    //    fragment = new InsightLibraryFragment();
                    //    fragment.RetainInstance = true;
                    //}
                    else
                    {
                        fragment = new LibraryFragment();
                        fragment.RetainInstance = true;
                    }

                    if (SelectedFragment != null)
                    {
                        transaction.Detach(SelectedFragment);
                    }
                    transaction.Add(Resource.Id.content_frame, fragment, tag);
                    transaction.Commit();
                }
                else
                {
                    transaction.Detach(SelectedFragment);
                    transaction.Attach(fragment);
                    transaction.Commit();
                }

                SelectedFragment = fragment;

                int index = App.STATE.Libraries.IndexOf(library);
                list.SetItemChecked(index, true);
                list.SetSelection(index);

                drawer.CloseDrawer(list);
            }
            else
            {
                // Temporary HACK
                SupportFragmentManager.PopBackStack(null, (int)PopBackStackFlags.Inclusive);

                SelectedFragment = null;
                transaction.Replace(Resource.Id.content_frame, new Fragment()).Commit();
                RunOnUiThread(() =>
                {
                    list.Adapter = null;
                });
            }

            Console.WriteLine("Current LibraryMode is " + App.STATE.CurrentLibrary.ToString());
        }
Пример #23
0
 private void SetMainFragment()
 {
     fragmentTransaction = SupportFragmentManager.BeginTransaction();
     fragmentTransaction.Add(Resource.Id.fragmentContainer, new OptionsGallery(), "Principal");
     fragmentTransaction.Commit();
 }
Пример #24
0
        public void OnCheckedChanged(RadioGroup group, int checkedId)
        {
            ft = SupportFragmentManager.BeginTransaction();
            TextView tvTopBar = FindViewById <TextView>(Resource.Id.txTopBar);

            hideFragment(ft);

            switch (checkedId)
            {
            case Resource.Id.rbExercise:
                if (fgExercise == null)
                {
                    fgExercise = new FragmentExercise();
                    ft.Add(Resource.Id.fragmentCanvas, fgExercise, "PAGE_EXERCISE");
                }
                else
                {
                    ft.Show(fgExercise);
                }
                tvTopBar.SetText(Resource.String.tab_menu_exercise);
                break;

            case Resource.Id.rbHealth:
                if (fgHealth == null)
                {
                    fgHealth = new FragmentHealth();
                    ft.Add(Resource.Id.fragmentCanvas, fgHealth, "PAGE_HEALTH");
                }
                else
                {
                    ft.Show(fgHealth);
                }
                tvTopBar.SetText(Resource.String.tab_menu_health);
                break;

            case Resource.Id.rbFind:
                if (fgFind == null)
                {
                    fgFind = new FragmentFind();
                    ft.Add(Resource.Id.fragmentCanvas, fgFind, "PAGE_FIND");
                }
                else
                {
                    ft.Show(fgFind);
                }
                tvTopBar.SetText(Resource.String.tab_menu_find);
                break;

            case Resource.Id.rbMe:
                if (fgMe == null)
                {
                    fgMe = new FragmentMe();
                    ft.Add(Resource.Id.fragmentCanvas, fgMe, "PAGE_ME");
                }
                else
                {
                    ft.Show(fgMe);
                }
                tvTopBar.SetText(Resource.String.tab_menu_me);
                break;
            }
            ft.Commit();
        }
Пример #25
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;
        }