< Summary

Class:PublishLandListView
Assembly:BuilderPublisher
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Publisher/ProjectPublishHUD/Scripts/Projects/PublishLandListView.cs
Covered lines:0
Uncovered lines:38
Coverable lines:38
Total lines:101
Line coverage:0% (0 of 38)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PublishLandListView()0%2100%
Awake()0%2100%
SetActive(...)0%2100%
SetContent(...)0%2100%
AddAdapters()0%6200%
RemoveAdapters()0%2100%
HideEmptyContent()0%2100%
SelectedLand(...)0%42600%
CreateAdapter(...)0%30500%
Update()0%2100%
HideIfClickedOutside()0%12300%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Publisher/ProjectPublishHUD/Scripts/Projects/PublishLandListView.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.Linq;
 5using UnityEngine;
 6
 7public class PublishLandListView : ListView<LandWithAccess>
 8{
 9    public event Action<LandWithAccess> OnLandSelected;
 10    public event Action<LandWithAccess> OnWrongLandSelected;
 11
 12    [SerializeField] internal PubllishLandListAdapter adapter;
 13
 014    private List<PubllishLandListAdapter> adapterList = new List<PubllishLandListAdapter>();
 15    private int projectRows;
 16    private int projectCols;
 17
 18    private bool selectedSet = false;
 19    private RectTransform rectTransform;
 20
 21    public void Awake()
 22    {
 023        rectTransform = GetComponent<RectTransform>();
 024    }
 25
 26    public void SetActive(bool isActive)
 27    {
 028        gameObject.SetActive(isActive);
 029    }
 30
 31    public void SetContent(int cols, int rows, List<LandWithAccess>lands)
 32    {
 033        contentPanelTransform.gameObject.SetActive( lands.Count > 0);
 034        projectCols = cols;
 035        projectRows = rows;
 036        selectedSet = false;
 37
 038        SetContent(lands);
 039    }
 40
 41    public override void AddAdapters()
 42    {
 043        base.AddAdapters();
 44
 045        foreach (LandWithAccess landWithAccess in contentList)
 46        {
 047            CreateAdapter(landWithAccess);
 48        }
 049    }
 50
 51    public override void RemoveAdapters()
 52    {
 053        base.RemoveAdapters();
 054        adapterList.Clear();
 055    }
 56
 57    public void HideEmptyContent()
 58    {
 059        emptyContentMark.SetActive(false);
 060    }
 61
 62    internal void SelectedLand(LandWithAccess land)
 63    {
 064        foreach (PubllishLandListAdapter adapter in adapterList)
 65        {
 066            if (adapter.GetLand() != land)
 67                continue;
 68
 069            if (adapter.GetState() == PubllishLandListAdapter.AdapterState.ENABLE)
 70            {
 071                OnLandSelected?.Invoke(land);
 072            }
 73            else
 74            {
 075                OnWrongLandSelected?.Invoke(land);
 76            }
 77        }
 078    }
 79
 80    internal void CreateAdapter(LandWithAccess land)
 81    {
 082        Vector2Int rowsAndColum = BIWUtils.GetRowsAndColumsFromLand(land);
 083        PubllishLandListAdapter instanciatedAdapter = Instantiate(adapter, contentPanelTransform).GetComponent<PubllishL
 084        var status = rowsAndColum.x >= projectCols && rowsAndColum.y >= projectRows && BIWUtils.HasSquareSize(land) ? Pu
 85
 086        instanciatedAdapter.SetContent(land, status);
 087        instanciatedAdapter.OnLandSelected += SelectedLand;
 088        adapterList.Add(instanciatedAdapter);
 089    }
 90
 091    private void Update() { HideIfClickedOutside(); }
 92
 93    private void HideIfClickedOutside()
 94    {
 095        if (Input.GetMouseButtonDown(0) &&
 96            !RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition))
 97        {
 098            SetActive(false);
 99        }
 0100    }
 101}