예제 #1
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);
        }
        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();
            //}
        }
예제 #3
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();
     }
 }
        internal static void addTab(SamplePlanningActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec, TabInfo tabInfo)
        {
            // Attach a Tab view factory to the spec
            tabSpec.SetContent(new TabFactory(activity));
            String tag = tabSpec.Tag;

            // Check to see if we already have a fragment for this tab, probably
            // from a previously saved state.  If so, deactivate it, because our
            // initial state is that a tab isn't shown.
            tabInfo.fragment = activity.SupportFragmentManager.FindFragmentByTag(tag);
            if (tabInfo.fragment != null && !tabInfo.fragment.IsDetached)
            {
                Android.Support.V4.App.FragmentTransaction ft = activity.SupportFragmentManager.BeginTransaction();
                ft.Detach(tabInfo.fragment);
                ft.Commit();
                activity.SupportFragmentManager.ExecutePendingTransactions();
            }

            tabHost.AddTab(tabSpec);
        }
        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());
        }