public void OnTabUnselected(ActionBar.Tab tab, FragmentTransaction ft)
            {
                if (_cleared)
                {
                    return;
                }
                var fragment = _content as Fragment;

                if (fragment != null)
                {
                    ft.Detach(fragment);
                    return;
                }
                var view = _content as View;

                if (view == null)
                {
                    return;
                }
                var viewGroup = view.Parent as ViewGroup;

                if (viewGroup != null)
                {
                    viewGroup.RemoveView(view);
                }
            }
示例#2
0
 public void OnTabUnselected(ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
 {
     if (fragment != null)
     {
         ft.Detach(fragment);
     }
 }
示例#3
0
        public void OnTabSelected(ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
        {
            switch (tab.Text)
            {
            case "Add Repairs":
                ft.Replace(Android.Resource.Id.Content, new LoadsFragmentRepairs2Loads());
                break;

            case "Close Load":
                ft.Replace(Android.Resource.Id.Content, new LoadsFragmentCloseLoads());
                break;
            }
        }
        public static void ClearTab(ActionBar bar, ActionBar.Tab tab, bool removeFragment)
        {
            var listener = ServiceProvider.AttachedValueProvider.GetValue <TabListener>(tab, ListenerKey, false);

            if (listener == null)
            {
                return;
            }
            BindingServiceProvider.BindingManager.ClearBindings(tab);
            if (removeFragment)
            {
                listener.Clear(bar, tab);
            }
            tab.ClearBindings(true, true);
        }
示例#5
0
        public void OnTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction)
        {
            // When the given tab is selected, switch to the corresponding page in
            // the ViewPager.
            int pos = tab.Position;

            mViewPager.CurrentItem = pos;

            Fragment fragment = ((FragmentPagerAdapter)mViewPager.Adapter).GetItem(pos);

            if (fragment is FragmentListener)
            {
                ((FragmentListener)fragment).OnFragmentSelected();
            }
        }
            public void Clear(ActionBar bar, ActionBar.Tab tab)
            {
                var fragment = _content as Fragment;

                if (fragment != null)
                {
                    (fragment.DataContext() as IViewModel)?.Settings.Metadata.Remove(ViewModelConstants.StateNotNeeded);
                    fragment.FragmentManager
                    ?.BeginTransaction()
                    .Remove(fragment)
                    .CommitAllowingStateLoss();
                }
                tab.SetBindingMemberValue(AttachedMembers.Object.Parent, value: null);
                _cleared = true;
            }
示例#7
0
        public void OnTabSelected(ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
        {
            if (fragment == null)
            {
                fragment = new SampleTabFragment();
                var id = (int)Build.VERSION.SdkInt >= 14 ?
                         Android.Resource.Id.Content :
                         Resource.Id.action_bar_activity_content;

                ft.Add(id, fragment, "tag");
            }
            else
            {
                ft.Attach(fragment);
            }
        }
示例#8
0
        public void OnTabSelected(ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
        {
            switch (tab.Text)
            {
            case "Receivals":
                ft.Replace(Android.Resource.Id.Content, new ReceivalsFragment());
                break;

            case "Repairs":
                ft.Replace(Android.Resource.Id.Content, new RepairsFragment());
                break;

            case "Loads":
                ft.Replace(Android.Resource.Id.Content, new LoadsFragment());
                break;
            }
        }
        public void OnTabSelected(ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
        {
            switch (tab.Text)
            {
            case "ListView":
                ft.Replace(Android.Resource.Id.Content, new ListViewFragment());
                break;

            case "RecyclerView":
                ft.Replace(Android.Resource.Id.Content, new RecyclerViewFragment());
                break;

            case "ScrollView":
                ft.Replace(Android.Resource.Id.Content, new ScrollViewFragment());
                break;
            }
        }
            public void OnTabSelected(ActionBar.Tab tab, FragmentTransaction ft)
            {
                if (_cleared)
                {
                    return;
                }
                var bar         = (ActionBar)tab.GetBindingMemberValue(AttachedMembers.Object.Parent);
                var placeHolder = ActionBarView.GetTabContentId(bar);
                var activity    = bar.ThemedContext.GetActivity();

                SetContent(tab, ft, placeHolder, activity, bar);
                //Set selected item data context or tab
                var selectedItem = bar.GetBindingMemberValue(ItemsSourceGeneratorBase.MemberDescriptor) == null ? tab : tab.DataContext();

#if APPCOMPAT
                bar.SetBindingMemberValue(AttachedMembersCompat.ActionBar.SelectedItem, selectedItem);
#else
                bar.SetBindingMemberValue(AttachedMembers.ActionBar.SelectedItem, selectedItem);
#endif
            }
示例#11
0
        public void OnTabSelected(ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
        {
            switch (tab.Text)
            {
            case "Pictures":
                if (_fpim == null)
                {
                    _fpim = new FragmentPicturesManagement();
                }
                ft.Replace(Android.Resource.Id.Content, _fpim);
                break;

            case "Parts":
                if (_fpam == null)
                {
                    _fpam = new FragmentPartsManagement();
                }
                ft.Replace(Android.Resource.Id.Content, _fpam);
                break;
            }
        }
        /// <summary>
        /// Called when [tab unselected].
        /// </summary>
        /// <param name="tab">The tab.</param>
        /// <param name="ft">The ft.</param>
        public void OnTabUnselected(AppTab tab, AppFragmentTransaction ft)
        {
            this.Log().Debug("Main => OnTabUnselected => {0}", tab.Tag);

            //// Select proper stack
            //Stack<String> backStack = _backStacks[(TabType)Convert.ToInt32(tab.Tag)];
            //// Get topmost fragment
            //String tag = backStack.Peek();
            //var fragment = SupportFragmentManager.FindFragmentByTag(tag);
            //// Detach it
            //ft.Detach(fragment);

            //if (TabUnselected != null)
            //{
            //    TabUnselected(fragment, null);
            //}
            //if (MainViewChanged != null)
            //{
            //    MainViewChanged(this, new MainViewChangedEventArgs());
            //}
        }
        // ITabListener

        #region public void OnTabSelected(AppTab tab, AppFragmentTransaction ft)

        /// <summary>
        /// Called when [tab selected].
        /// </summary>
        /// <param name="tab">The tab.</param>
        /// <param name="ft">The ft.</param>
        /// <exception cref="Java.Lang.IllegalArgumentException">Unknown TabType</exception>
        public void OnTabSelected(AppTab tab, AppFragmentTransaction ft)
        {
            var tabType = Convert.ToString(tab.Tag);

            if (String.Compare(tabType, "WatchList", StringComparison.OrdinalIgnoreCase) == 0)
            {
                ActiveTab = TabType.WatchList;
            }
            else if (String.Compare(tabType, "Search", StringComparison.OrdinalIgnoreCase) == 0)
            {
                ActiveTab = TabType.Search;
            }
            else if (String.Compare(tabType, "Settings", StringComparison.OrdinalIgnoreCase) == 0)
            {
                ActiveTab = TabType.Settings;
            }
            else
            {
                throw new Exception("Unknown TabType");
            }

            this.ViewModel.SelectTab(ActiveTab, _suppressTabSelected);
            _suppressTabSelected = false;
        }
示例#14
0
 public void OnTabUnselected(SupportActionBar.Tab tab, SupportFragmentTransaction fragmentTransaction)
 {
     this.TabListener.OnTabUnselected(this.Tab, null);
 }
        /// <summary>
        /// Called when [tab reselected].
        /// </summary>
        /// <param name="tab">The tab.</param>
        /// <param name="ft">The ft.</param>
        public void OnTabReselected(AppTab tab, AppFragmentTransaction ft)
        {
            this.Log().Debug("Main => OnTabReselected => {0}", tab.Tag);

            OnTabSelected(tab, ft);
        }
示例#16
0
 public void OnTabUnselected(ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
 {
 }
            private void SetContent(ActionBar.Tab tab, FragmentTransaction ft, int?placeHolder, Activity activity, ActionBar bar)
            {
                if (placeHolder == null)
                {
                    Tracer.Error("The placeholder for tab {0} was not found.", tab);
                    return;
                }
                var layout = activity.FindViewById <ViewGroup>(placeHolder.Value);

                if (layout == null)
                {
                    Tracer.Warn("The ActionBarTabContentId with id = {0} is not found in activity {1}",
                                placeHolder.Value,
                                activity);
                    return;
                }
                if (_content == null)
                {
#if APPCOMPAT
                    _content = tab.GetBindingMemberValue(AttachedMembersCompat.ActionBarTab.Content);
#else
                    _content = tab.GetBindingMemberValue(AttachedMembers.ActionBarTab.Content);
#endif

                    var viewModel = _content as IViewModel;
                    if (viewModel == null)
                    {
                        var fragmentClass = _content as string;
                        //If content is a string, trying to create a fragment.
                        if (!string.IsNullOrEmpty(fragmentClass))
                        {
                            var type = TypeCache <Fragment> .Instance.GetTypeByName(fragmentClass, true, false);

                            if (type != null)
                            {
                                var fragment = Fragment.Instantiate(bar.ThemedContext, Java.Lang.Class.FromType(type).Name);
                                _content = fragment;
                            }
                        }
                        else if (_content is int)
                        {
                            _content = activity.GetBindableLayoutInflater().Inflate((int)_content, null);
                        }
                    }
                    else
                    {
                        viewModel.Settings.Metadata.AddOrUpdate(ViewModelConstants.StateNotNeeded, true);
                    }
                    _content = PlatformExtensions.GetContentView(layout, layout.Context, _content,
                                                                 _contentTemplateProvider.GetTemplateId(), _contentTemplateProvider.GetDataTemplateSelector());
                    if (BindingServiceProvider.BindingManager.GetBindings(tab, AttachedMembers.Object.DataContext).Any())
                    {
                        _content.SetBindingMemberValue(AttachedMembers.Object.Parent, tab);
                    }
                    layout.SetContentView(_content, ft, (@group, fragment, arg3) =>
                    {
                        if (fragment.IsDetached)
                        {
                            arg3.Attach(fragment);
                        }
                        else
                        {
                            arg3.Replace(@group.Id, fragment);
                        }
                    });
                }
                else
                {
                    layout.SetContentView(_content, ft, (@group, fragment, arg3) => arg3.Attach(fragment));
                }
            }
示例#18
0
 public void OnTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction)
 {
 }
示例#19
0
 internal static ActionBar.Tab ForSupportTab(SupportActionBar.Tab supportTab)
 {
     return(TabMappings[supportTab]);
 }
示例#20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TabAdapter"/> class.
 /// </summary>
 /// <param name="supportTab">The support tab.</param>
 public TabAdapter(SupportActionBar.Tab supportTab)
 {
     this.SupportTab = supportTab;
     TabMappings.Add(supportTab, this);
 }
示例#21
0
        public void Apply(Activity activity)
        {
            AndroidToolkitExtensions.ValidateTemplate(ItemsSource, Items);
            var actionBar = activity.GetActionBar();

            var setter = new XmlPropertySetter(actionBar, activity);

            setter.SetEnumProperty <ActionBarNavigationMode>(nameof(NavigationMode), NavigationMode);
            setter.SetProperty(nameof(DataContext), DataContext);

            if (!string.IsNullOrEmpty(Bind))
            {
                setter.Bind(actionBar, Bind);
            }
            setter.SetProperty(nameof(ContextActionBarTemplate), ContextActionBarTemplate);
            setter.SetBinding(nameof(ContextActionBarVisible), ContextActionBarVisible, false);
            setter.SetProperty(nameof(BackgroundDrawable), BackgroundDrawable);
            setter.SetProperty(nameof(CustomView), CustomView);
            setter.SetEnumProperty <ActionBarDisplayOptions>(nameof(DisplayOptions), DisplayOptions);
            setter.SetBoolProperty(nameof(DisplayHomeAsUpEnabled), DisplayHomeAsUpEnabled);
            setter.SetBoolProperty(nameof(DisplayShowCustomEnabled), DisplayShowCustomEnabled);
            setter.SetBoolProperty(nameof(DisplayShowHomeEnabled), DisplayShowHomeEnabled);
            setter.SetBoolProperty(nameof(DisplayShowTitleEnabled), DisplayShowTitleEnabled);
            setter.SetBoolProperty(nameof(DisplayUseLogoEnabled), DisplayUseLogoEnabled);
            setter.SetBoolProperty(nameof(HomeButtonEnabled), HomeButtonEnabled);
            setter.SetProperty(nameof(Icon), Icon);
            setter.SetProperty(nameof(Logo), Logo);
            setter.SetProperty(nameof(SplitBackgroundDrawable), SplitBackgroundDrawable);
            setter.SetProperty(nameof(StackedBackgroundDrawable), StackedBackgroundDrawable);
            setter.SetBoolProperty(nameof(IsShowing), IsShowing);
            setter.SetStringProperty(nameof(Subtitle), Subtitle);
            setter.SetStringProperty(nameof(Title), Title);
            setter.SetBoolProperty(nameof(Visible), Visible);
            setter.SetBinding(AttachedMembers.ActionBar.HomeButtonClick, HomeButtonClick, false);

            if (string.IsNullOrEmpty(ItemsSource))
            {
                if (Items != null)
                {
                    ActionBar.Tab firstTab = null;
                    for (int index = 0; index < Items.Count; index++)
                    {
                        var tab = Items[index].CreateTab(actionBar);
                        if (firstTab == null)
                        {
                            firstTab = tab;
                        }
                        actionBar.AddTab(tab);
                    }
                    TryRestoreSelectedIndex(activity, actionBar);
                }
            }
            else
            {
#if APPCOMPAT
                actionBar.SetBindingMemberValue(AttachedMembersCompat.ActionBar.ItemsSourceGenerator, new ActionBarTabItemsSourceGenerator(actionBar, TabTemplate));
#else
                actionBar.SetBindingMemberValue(AttachedMembers.ActionBar.ItemsSourceGenerator, new ActionBarTabItemsSourceGenerator(actionBar, TabTemplate));
#endif
                setter.SetBinding(nameof(ItemsSource), ItemsSource, false);
            }
            setter.SetBinding(nameof(SelectedItem), SelectedItem, false);
            setter.Apply();
        }
 public void OnTabReselected(ActionBar.Tab tab, FragmentTransaction ft)
 {
 }
        public void Apply(Activity activity)
        {
            PlatformExtensions.ValidateTemplate(ItemsSource, Tabs);
            var actionBar = activity.GetActionBar();

            var setter = new XmlPropertySetter <ActionBarTemplate, ActionBar>(actionBar, activity, new BindingSet());

            setter.SetEnumProperty <ActionBarNavigationMode>(() => template => template.NavigationMode, NavigationMode);
            setter.SetProperty(() => template => template.DataContext, DataContext);

            if (!string.IsNullOrEmpty(Bind))
            {
                setter.BindingSet.BindFromExpression(actionBar, Bind);
            }
            setter.SetProperty(() => template => template.ContextActionBarTemplate, ContextActionBarTemplate);
            setter.SetBinding(() => template => template.ContextActionBarVisible, ContextActionBarVisible, false);
            setter.SetProperty(() => template => template.BackgroundDrawable, BackgroundDrawable);
            setter.SetProperty(() => template => template.CustomView, CustomView);
            setter.SetEnumProperty <ActionBarDisplayOptions>(() => template => template.DisplayOptions, DisplayOptions);
            setter.SetBoolProperty(() => template => template.DisplayHomeAsUpEnabled, DisplayHomeAsUpEnabled);
            setter.SetBoolProperty(() => template => template.DisplayShowCustomEnabled, DisplayShowCustomEnabled);
            setter.SetBoolProperty(() => template => template.DisplayShowHomeEnabled, DisplayShowHomeEnabled);
            setter.SetBoolProperty(() => template => template.DisplayShowTitleEnabled, DisplayShowTitleEnabled);
            setter.SetBoolProperty(() => template => template.DisplayUseLogoEnabled, DisplayUseLogoEnabled);
            setter.SetBoolProperty(() => template => template.HomeButtonEnabled, HomeButtonEnabled);
            setter.SetProperty(() => template => template.Icon, Icon);
            setter.SetProperty(() => template => template.Logo, Logo);
            setter.SetProperty(() => template => template.SplitBackgroundDrawable, SplitBackgroundDrawable);
            setter.SetProperty(() => template => template.StackedBackgroundDrawable, StackedBackgroundDrawable);
            setter.SetBoolProperty(() => template => template.IsShowing, IsShowing);
            setter.SetStringProperty(() => template => template.Subtitle, Subtitle);
            setter.SetStringProperty(() => template => template.Title, Title);
            setter.SetBoolProperty(() => template => template.Visible, Visible);
            setter.SetBinding("HomeButton.Click", HomeButtonClick, false);

            if (string.IsNullOrEmpty(ItemsSource))
            {
                if (Tabs != null)
                {
                    ActionBar.Tab firstTab = null;
                    for (int index = 0; index < Tabs.Count; index++)
                    {
                        var tab = Tabs[index].CreateTab(actionBar);
                        if (firstTab == null)
                        {
                            firstTab = tab;
                        }
                        actionBar.AddTab(tab);
                    }
                    TryRestoreSelectedIndex(activity, actionBar);
                }
            }
            else
            {
#if APPCOMPAT
                actionBar.SetBindingMemberValue(AttachedMembersCompat.ActionBar.ItemsSourceGenerator, new ActionBarTabItemsSourceGenerator(actionBar, TabTemplate));
#else
                actionBar.SetBindingMemberValue(AttachedMembers.ActionBar.ItemsSourceGenerator, new ActionBarTabItemsSourceGenerator(actionBar, TabTemplate));
#endif
                setter.SetBinding(() => template => template.ItemsSource, ItemsSource, false);
            }
            setter.SetBinding(() => template => template.SelectedItem, SelectedItem, false);
            setter.Apply();
        }