Beispiel #1
0
 private void OnListUpdate(ListUpdateArgs args)
 {
     if (UpdateListVisibility())
     {
         currentView.OnListUpdate(args);
     }
 }
Beispiel #2
0
        public void OnListUpdate(ListUpdateArgs args)
        {
            var rebuildCalled = UpdateItemsSource(args.page.visualStates.ToList(), args.added.Any() || args.removed.Any());

            if (!rebuildCalled)
            {
                foreach (var package in args.updated)
                {
                    GetPackageItem(package.uniqueId)?.SetPackageAndVisualState(package, m_PageManager.GetCurrentPage().GetVisualState(package.uniqueId));
                }
            }

            if (m_PageManager.UpdateSelectionIfCurrentSelectionIsInvalid())
            {
                ScrollToSelection();
            }
        }
        public void OnListUpdate(ListUpdateArgs args)
        {
            var page     = args.page;
            var numItems = m_PackageItemsLookup.Count;

            foreach (var package in args.removed)
            {
                RemovePackageItem(package?.uniqueId);
            }

            var itemsRemoved = numItems != m_PackageItemsLookup.Count;

            numItems = m_PackageItemsLookup.Count;

            foreach (var package in args.added.Concat(args.updated))
            {
                var visualState = page.GetVisualState(package.uniqueId) ?? new VisualState(package.uniqueId, string.Empty, page.GetDefaultLockState(package));
                AddOrUpdatePackageItem(visualState, package);
            }
            var itemsAdded = numItems != m_PackageItemsLookup.Count;

            if (args.reorder)
            {
                if (packageGroups.Any(group => !group.isHidden))
                {
                    // re-order if there are any added or updated items
                    foreach (var group in packageGroups)
                    {
                        group.ClearPackageItems();
                    }

                    foreach (var state in page.visualStates)
                    {
                        var packageItem = GetPackageItem(state.packageUniqueId);

                        // For when user switch account and packageList gets refreshed
                        packageItem?.packageGroup.AddPackageItem(packageItem);
                    }

                    m_PackageItemsLookup = packageItems.ToDictionary(item => item.package.uniqueId, item => item);
                }
            }

            if (itemsRemoved || itemsAdded)
            {
                ReorderGroups();
                foreach (var group in packageGroups)
                {
                    group.RefreshHeaderVisibility();
                }

                if (m_PageManager.UpdateSelectionIfCurrentSelectionIsInvalid())
                {
                    ScrollToSelection();
                }
            }
            else
            {
                ReorderGroups();
            }
        }
 private void TriggerOnPageUpdate(ListUpdateArgs args)
 {
     onListUpdate?.Invoke(args);
 }