public void Populate(BaseCardData data, UIEventListener.VoidDelegate onClickedDelegate = null, bool allowRecommending = false) { this.data = data; ShowSponsors(null != data as SponsorDataModel); if (activityParent.activeSelf) { titleLabel.text = data.title; global::System.DateTime date = data.ParseDateString(); companyLabel.text = data.company; timeDistanceLabel.text = date.ToString("t", global::System.Globalization.CultureInfo.CreateSpecificCulture("en-us")) + " | " + data.Proximity.ToString("#.##") + " miles"; nid = data.id; costLabel.text = (data.admission_adults <= 0) && (data.admission_children <= 0) ? "FREE" : " $ "; SetCategoryIcon(data.category); SetCardIcon(data.featured); if (null != data.image && !string.IsNullOrEmpty(data.image.serving_url)) { data.StartImageDownload(UpdatePrimaryImage, null); } // Grab a placeholder image during the download. primaryImage.mainTexture = PlaceholderImageManager.Instance.GetRandomImage((int)data.id); UIEventListener myListener = UIEventListener.Get(gameObject); myListener.onClick -= OnSponsorWebsitePressed; if (null != onClickedDelegate) { myListener.onClick -= onClickedDelegate; myListener.onClick += onClickedDelegate; } } else { SponsorDataModel sponsorData = data as SponsorDataModel; sponsorWebURL = sponsorData.website; if (null != sponsorData.image && !string.IsNullOrEmpty(sponsorData.image.serving_url)) { sponsorData.StartImageDownload(UpdatePrimaryImage, null); } // Grab a placeholder image during the download. sponsorImage.mainTexture = PlaceholderImageManager.Instance.GetRandomImage((int)data.id); UIEventListener myListener = UIEventListener.Get(gameObject); // Sponsors have a different onClick myListener.onClick -= onClickedDelegate; myListener.onClick -= OnSponsorWebsitePressed; myListener.onClick += OnSponsorWebsitePressed; } isPopulated = true; }
public void Populate(BaseCardData data, UIEventListener.VoidDelegate onClickedDelegate = null, bool allowRecommending = false) { this.data = data; titleLabel.text = data.title; global::System.DateTime date = data.ParseDateString(); companyLabel.text = data.company; timeDistanceLabel.text = date.ToString("t", global::System.Globalization.CultureInfo.CreateSpecificCulture("en-us")) + " | " + data.Proximity.ToString("#.##") + " miles"; nid = data.id; if (null != onClickedDelegate) { UIEventListener.Get(gameObject).onClick -= onClickedDelegate; UIEventListener.Get(gameObject).onClick += onClickedDelegate; } // change image to recommend icon for activities only, if they are past if (allowRecommending && ITTDataCache.Instance.HasSessionCredentials) { preRecommendRoot.SetActive(false); postRecommendRoot.SetActive(false); ITTDataCache.Instance.IsFlaggedRecommended(nid, OnCheckRecommendFlagSuccess, OnCheckRecommendFlagFailure); } if (null == data.image || string.IsNullOrEmpty(data.image.serving_url)) { // Grab a placeholder image mainImage.mainTexture = PlaceholderImageManager.Instance.GetRandomImage((int)data.id); } else { data.StartImageDownload(UpdateImage, OnImageImportFailed); } if (data.category.Contains("hysic")) categorySprite.spriteName = "Category_PhysicalActivity_Inside"; else if (data.category.Contains("ellness")) categorySprite.spriteName = "Category_HealthWellness_Inside"; else if (data.category.Contains("ood")) categorySprite.spriteName = "Category_FoodNutrition_Inside"; priceLabel.text = (data.admission_adults <= 0) && (data.admission_children <= 0)? "FREE" : " $ "; if (data.featured) { activityTypeSprite.spriteName = "Activity_Sponsored"; } else { activityTypeSprite.spriteName = "Activity_Normal"; } }