Exemplo n.º 1
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);
	}