private ActionBarTabItemsSourceGenerator(ActionBar actionBar, ActionBarTabTemplate tabTemplate)
 {
     Should.NotBeNull(actionBar, "actionBar");
     Should.NotBeNull(tabTemplate, "tabTemplate");
     _actionBar   = actionBar;
     _tabTemplate = tabTemplate;
     TryListenActivity(_actionBar.ThemedContext);
 }
 internal ActionBarTabItemsSourceGenerator(ActionBar actionBar, ActionBarTabTemplate tabTemplate)
 {
     Should.NotBeNull(actionBar, "actionBar");
     Should.NotBeNull(tabTemplate, "tabTemplate");
     _actionBar = actionBar;
     _tabTemplate = tabTemplate;
     TryListenActivity(_actionBar.ThemedContext);
 }
Exemplo n.º 3
0
        private void Remove(int index)
        {
            var tabAt = _actionBar.GetTabAt(index);

            _actionBar.RemoveTabAt(index);
            if (tabAt != null)
            {
                ActionBarTabTemplate.ClearTab(_actionBar, tabAt, true);
            }
        }
 internal ActionBarTabItemsSourceGenerator(ActionBar actionBar, ActionBarTabTemplate tabTemplate)
 {
     Should.NotBeNull(actionBar, "actionBar");
     Should.NotBeNull(tabTemplate, "tabTemplate");
     _actionBar = actionBar;
     _tabTemplate = tabTemplate;
     _collectionViewManagerMember = BindingServiceProvider
         .MemberProvider
         .GetBindingMember(actionBar.GetType(), AttachedMembers.ActionBar.CollectionViewManager, false, false);
     TryListenActivity(_actionBar.ThemedContext);
 }
Exemplo n.º 5
0
 internal ActionBarTabItemsSourceGenerator(ActionBar actionBar, ActionBarTabTemplate tabTemplate)
 {
     Should.NotBeNull(actionBar, nameof(actionBar));
     Should.NotBeNull(tabTemplate, nameof(tabTemplate));
     _actionBar   = actionBar;
     _tabTemplate = tabTemplate;
     _collectionViewManagerMember = BindingServiceProvider
                                    .MemberProvider
                                    .GetBindingMember(actionBar.GetType(), AttachedMembers.ActionBar.CollectionViewManager, false, false);
     TryListenActivity(_actionBar.ThemedContext);
 }
Exemplo n.º 6
0
        public static void Clear(Activity activity)
        {
            var actionBar = activity.GetActionBar(false);

            if (actionBar == null)
            {
                return;
            }
            for (int i = 0; i < actionBar.TabCount; i++)
            {
                ActionBarTabTemplate.ClearTab(actionBar, actionBar.GetTabAt(i), false);
            }
            actionBar.ClearBindings(true, true);
        }
Exemplo n.º 7
0
        protected override void Refresh()
        {
            var manager = GetCollectionViewManager();

            for (int i = 0; i < _actionBar.TabCount; i++)
            {
                ActionBarTabTemplate.ClearTab(_actionBar, _actionBar.GetTabAt(i), true);
            }
            if (manager == null)
            {
                _actionBar.RemoveAllTabs();
            }
            else
            {
                manager.Clear(_actionBar);
            }

            IEnumerable itemsSource = ItemsSource;

            if (itemsSource == null)
            {
                return;
            }

#if APPCOMPAT
            var selectedItem = _actionBar.GetBindingMemberValue(AttachedMembersCompat.ActionBar.SelectedItem);
#else
            var selectedItem = _actionBar.GetBindingMemberValue(AttachedMembers.ActionBar.SelectedItem);
#endif
            int count = itemsSource.Count();
            for (int index = 0; index < count; index++)
            {
                var item = GetItem(index);
                var tab  = CreateTab(item);
                if (manager == null)
                {
                    _actionBar.AddTab(tab, index, ReferenceEquals(selectedItem, item));
                }
                else
                {
                    manager.Insert(_actionBar, index, tab);
                }
            }
            if (count == 0)
            {
                OnEmptyTab();
            }
        }
 public static void Set(ActionBar actionBar, ActionBarTabTemplate tabTemplate)
 {
     ServiceProvider.AttachedValueProvider.SetValue(actionBar, Key, new ActionBarTabItemsSourceGenerator(actionBar, tabTemplate));
 }