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"; } }
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 SetBaseCardData(BaseCardData ddm) { ITTGoogleAnalytics.Instance.googleAnalytics.LogScreen("Detail Card"); ITTGoogleAnalytics.Instance.googleAnalytics.LogEvent(new EventHitBuilder() .SetEventCategory("Detail - Detail Card") .SetEventAction("Detail Clicked - Detail Card") .SetEventLabel("Detail Card clicked Nid: " + ddm.id + " Name: " + ddm.title)); if (Application.platform == RuntimePlatform.Android) RecommendCountByDefault(); ITTDataCache.Instance.GetRecommendedFlagCount(Nid, OnRecommendCountReceived, OnRecommendCountFailure); ITTDataCache.Instance.IsFlaggedSaved(Nid, OnItemSaveCheckSuccess, OnItemSaveCheckFailure); titleLabel.text = string.IsNullOrEmpty(ddm.title) ? "N/A" : ddm.title; categoryName.text = string.IsNullOrEmpty(ddm.category) ? "N/A" : ddm.category; if (null != ddm.image && !string.IsNullOrEmpty(ddm.image.serving_url)) imageServingURL = ddm.image.serving_url; NGUITools.SetActive(categoryIcon.gameObject, true); if (categoryName.text.Contains("hysic")) categoryIcon.spriteName = "Category_PhysicalActivity_Inside"; else if (categoryName.text.Contains("ellness")) categoryIcon.spriteName = "Category_HealthWellness_Inside"; else if (categoryName.text.Contains("ood")) categoryIcon.spriteName = "Category_FoodNutrition_Inside"; detailLabel.text = HelperMethods.Instance.StripHtmlTags(ddm.Description); if (string.IsNullOrEmpty(detailLabel.text)) detailLabel.text = "N/A"; companyLabel.text = ddm.company; DateTime localDate = ddm.ParseDateString(); if (null != localDate && DateTime.MinValue != localDate) { dateLabel.text = localDate.DayOfWeek.ToString() + " " + localDate.Month + "/" + localDate.Day; timeLabel.text = localDate.ToString("t", global::System.Globalization.CultureInfo.CreateSpecificCulture("en-us")); } if(string.IsNullOrEmpty(ddm.phone)) { phoneNumberButton.GetComponent<UIWidget>().bottomAnchor.absolute = 0; NGUITools.SetActiveChildren(phoneNumberButton.gameObject, false); } else { phoneNumberTextLabel.text = ddm.phone; UIEventListener.Get(phoneNumberButton.gameObject).onClick += OnPhoneButtonPressed; } if(string.IsNullOrEmpty(ddm.website)) { Website = ""; websiteLabel.text = "No Website"; } else { Website = ddm.website; UIEventListener.Get(websiteButton.gameObject).onClick += OnWebsiteButtonPressed; } locationNameTextLabel.text = string.IsNullOrEmpty(ddm.company) ? "N/A" : ddm.company; locationAddressTextLabel.text = string.IsNullOrEmpty(ddm.address.address) ? "N/A" : ddm.address.address; latitude = ddm.address.lat; longitude = ddm.address.lon; UIEventListener.Get(mapButton.gameObject).onClick += OnMapButtonPressed; ITTDataCache.Instance.GetStaticMapImage(locationAddressTextLabel.text, OnStaticMapImageReceived, OnStaticMapImageFailure); suggestedAudienceTextLabel.text = GenerateAudienceLabel(ddm); suggestedSkillTextLabel.text = GenerateSkillLabel(ddm); if (ddm.admission_adults > 0) { string price = ddm.admission_adults.ToString(); string currencySymbol = !price.StartsWith("$") ? "$" : ""; adultPriceTextLabel.text = currencySymbol + price; } else { adultPriceTextLabel.text = (ddm.audience_adults) ? "FREE" : "N/A"; } if (ddm.admission_children > 0) { string price = ddm.admission_children.ToString(); string currencySymbol = !price.StartsWith("$") ? "$" : ""; childPriceTextLabel.text = currencySymbol + price; } else { childPriceTextLabel.text = (ddm.audience_kids) ? "FREE" : "N/A"; } if (ddm.card_discount > 0) cardDiscountTextLabel.text = ddm.card_discount.ToString() + "%"; else cardDiscountTextLabel.text = "N/A"; }