Exemplo n.º 1
0
    public void Init(int width, int height, float cardPadding, BoolDelegate onCarouselSwap, BoolDelegate onShowEndOfDayCard, int carouselLength = -1, bool clearOnRepopulate = true, bool verticalMode = false, bool allowRecommending = false)
    {
        _verticalMode                        = verticalMode;
        _cardPadding                         = cardPadding;
        HideNoResultsCardDelegate            = onCarouselSwap;
        SetEndOfDayNoResultsCardTextDelegate = onShowEndOfDayCard;

        // Initialize carousels and populate with blank cards
        if (null == _mainCarousel)
        {
            GameObject mainCarouselObject = NGUITools.AddChild(gameObject);
            mainCarouselObject.name = "MainCarousel";
            _mainCarousel           = mainCarouselObject.AddComponent <CardCarousel>();
        }
        int dayIndex = (!_verticalMode ? dayOfWeekController.SelectedDay.IndexOfDay : -1);

        _mainCarousel.Init(dayIndex, width, height, cardPadding, PresentDetailCardHelper, carouselLength, clearOnRepopulate, _verticalMode, allowRecommending);
        _mainCarousel.OnNoCardsForSelectedDay = InvokeShowNoResultsCard;
        if (null == _secondaryCarousel)
        {
            GameObject secondaryCarouselObject = NGUITools.AddChild(gameObject);
            secondaryCarouselObject.name = "SecondaryCarousel";
            _secondaryCarousel           = secondaryCarouselObject.AddComponent <CardCarousel>();
        }
        if (!_verticalMode)
        {
            // If the next day index is out of bounds, init with prev just so he's initialized with something.
            int curIndex          = dayOfWeekController.SelectedDay.IndexOfDay;
            int secondaryDayIndex = curIndex == dayOfWeekController.NumberOfDays - 1 ? curIndex - 1 : curIndex + 1;
            _secondaryCarousel.Init(secondaryDayIndex, width, height, cardPadding, PresentDetailCardHelper, carouselLength, clearOnRepopulate, _verticalMode, allowRecommending);
            _secondaryCarousel.OnNoCardsForSelectedDay = InvokeShowNoResultsCard;
        }
    }
Exemplo n.º 2
0
    private IEnumerator AnimateAndPopulateNewCarousel(int indexOfDay)
    {
        // Disable No Cards label regardless every time
        HideNoResultsCard(true);

        int oldDayIndex = _mainCarousel.DayIndex;
        // Main carousel should now be this, and secondary should be what main was.
        CardCarousel temp = _secondaryCarousel;

        _secondaryCarousel = _mainCarousel;
        _mainCarousel      = temp;

        Resources.UnloadUnusedAssets();
        _mainCarousel.DayIndex = indexOfDay;


        // Start animation, based on direction
        int direction = indexOfDay - oldDayIndex;
        // - backwards, + forwards
        bool movingForward = direction > 0;

        loadingIcon.SetActive(true);

        if (_secondaryCarousel.gameObject.activeInHierarchy)
        {
            yield return(StartCoroutine(_secondaryCarousel.AnimateFade(movingForward, HelperMethods.TypeOfAnimation.AnimationOut, true)));
        }

        isMainCarouselPopulated      = false;
        isMainCarouselPopulateFailed = false;
        ITTDataCache.Instance.Data.GetDataEntry((int)DataCacheIndices.ACTIVITY_LIST, Populate, OnPopulateFailure);

        while (!isMainCarouselPopulated)
        {
            yield return(null);

            if (isMainCarouselPopulateFailed)
            {
                loadingIcon.SetActive(false);
                yield break;
            }
        }

        yield return(StartCoroutine(_mainCarousel.AnimateFade(!movingForward, HelperMethods.TypeOfAnimation.AnimationIn, false)));

        loadingIcon.SetActive(false);
    }