< Summary

Class:CatalogGroupListView
Assembly:BuilderInWorldCatalog
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/Catalog/UI/CatalogGroupListView.cs
Covered lines:7
Uncovered lines:29
Coverable lines:36
Total lines:83
Line coverage:19.4% (7 of 36)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AddAdapters()0%30500%
RemoveAdapters()0%42600%
SubscribeToEvents(...)0%110100%
UnsubscribeToEvents(...)0%2100%
AdapterStartDragging(...)0%220100%
CatalogItemSelected(...)0%6200%
CatalogItemFavorite(...)0%6200%
OnPointerEnter(...)0%6200%
OnPointerExit(...)0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/Catalog/UI/CatalogGroupListView.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using UnityEngine;
 3using UnityEngine.EventSystems;
 4
 5public class CatalogGroupListView : ListView<Dictionary<string, List<CatalogItem>>>
 6{
 7    public Canvas generalCanvas;
 8    public CatalogAssetGroupAdapter categoryItemAdapterPrefab;
 9    public DynamicScrollSensitivity dynamicScrollSensitivity;
 10
 11    public System.Action<CatalogItem> OnCatalogItemClicked;
 12    public System.Action<CatalogItem, CatalogItemAdapter> OnCatalogItemStarDragging;
 13    public System.Action<CatalogItem, CatalogItemAdapter> OnCatalogItemFavorite;
 14    public System.Action<PointerEventData, CatalogItemAdapter> OnPointerEnterInAdapter;
 15    public System.Action<PointerEventData, CatalogItemAdapter> OnPointerExitInAdapter;
 16
 17    public override void AddAdapters()
 18    {
 019        base.AddAdapters();
 20
 021        if (contentList == null)
 022            return;
 23
 024        foreach (Dictionary<string, List<CatalogItem>> assetPackGroups in contentList)
 25        {
 026            foreach (KeyValuePair<string, List<CatalogItem>> assetPackGroup in assetPackGroups)
 27            {
 028                CatalogAssetGroupAdapter adapter = Instantiate(categoryItemAdapterPrefab, contentPanelTransform).GetComp
 029                adapter.SetContent(assetPackGroup.Key, assetPackGroup.Value);
 030                SubscribeToEvents(adapter);
 31            }
 32        }
 33
 034        if (dynamicScrollSensitivity != null)
 035            dynamicScrollSensitivity.RecalculateSensitivity();
 036    }
 37
 38    public override void RemoveAdapters()
 39    {
 040        if (contentPanelTransform == null ||
 41            contentPanelTransform.transform == null ||
 42            contentPanelTransform.transform.childCount == 0)
 043            return;
 44
 045        for (int i = 0; i < contentPanelTransform.transform.childCount; i++)
 46        {
 047            CatalogAssetGroupAdapter toRemove = contentPanelTransform.transform.GetChild(i).GetComponent<CatalogAssetGro
 048            if (toRemove != null)
 49            {
 050                UnsubscribeToEvents(toRemove);
 051                Destroy(toRemove.gameObject);
 52            }
 53        }
 054    }
 55
 56    public void SubscribeToEvents(CatalogAssetGroupAdapter adapter)
 57    {
 158        adapter.OnCatalogItemClicked += CatalogItemSelected;
 159        adapter.OnCatalogItemFavorite += CatalogItemFavorite;
 160        adapter.OnAdapterStartDragging += AdapterStartDragging;
 161        adapter.OnPointerEnterInAdapter += OnPointerEnter;
 162        adapter.OnPointerExitInAdapter += OnPointerExit;
 163    }
 64
 65    public void UnsubscribeToEvents(CatalogAssetGroupAdapter adapter)
 66    {
 067        adapter.OnCatalogItemClicked -= CatalogItemSelected;
 068        adapter.OnCatalogItemFavorite -= CatalogItemFavorite;
 069        adapter.OnAdapterStartDragging -= AdapterStartDragging;
 070        adapter.OnPointerEnterInAdapter -= OnPointerEnter;
 071        adapter.OnPointerExitInAdapter -= OnPointerExit;
 072    }
 73
 1874    private void AdapterStartDragging(CatalogItem catalogItemClicked, CatalogItemAdapter adapter, BaseEventData data) { 
 75
 076    private void CatalogItemSelected(CatalogItem sceneObject) { OnCatalogItemClicked?.Invoke(sceneObject); }
 77
 078    private void CatalogItemFavorite(CatalogItem sceneObject, CatalogItemAdapter adapter) { OnCatalogItemFavorite?.Invok
 79
 080    private void OnPointerEnter(PointerEventData eventData, CatalogItemAdapter adapter) { OnPointerEnterInAdapter?.Invok
 81
 082    private void OnPointerExit(PointerEventData eventData, CatalogItemAdapter adapter) { OnPointerExitInAdapter?.Invoke(
 83}