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"; } }
private void OnCheckRecommendFlagFailure(string error, BaseCardData baseCard) { Debug.LogError("RecommendationController.OnCheckRecommendFlagFailure error: " + error + " uid:" + baseCard.id + " " + baseCard.title); }
private RecommendationNotification GetRecommendation(BaseCardData baseCard) { return RecommendationList.FirstOrDefault(card => card.Nid == baseCard.id); }
public void OnDismissedCard(BaseCardData baseCard) { _currentlyShowing = false; if (baseCard == null) return; RecommendationNotification recommendation = GetRecommendation(baseCard); if (recommendation != null) { recommendation.State = RecommendationState.Skip; } }
public void OnRecommendButton(BaseCardData baseCard) { Debug.Log("RecommendationController.OnRecommendButton - OK"); RecommendationNotification recommendation = GetRecommendation(baseCard); if (null == recommendation) { throw new NullReferenceException("RecommendationController.OnRecommendButton - can't get card: " + baseCard.title); } recommendation.State = RecommendationState.Recommended; _currentlyShowing = false; ITTGoogleAnalytics.Instance.googleAnalytics.LogEvent(new EventHitBuilder() .SetEventCategory("Notification - Recommendation") .SetEventAction("Click - Recommend Button") .SetEventLabel("User clicked recommend button for card id: " + baseCard.id + " " + baseCard.title)); ITTDataCache.Instance.RetrieveProfileActivityID((Int64)baseCard.id, OnRetrieveProfileActivitySuccess, OnRetrieveProfileActivityFailure); }
private void AddRecommendationToView(BaseCardData cardData) { //AddRecommendationToView(baseCard); if (OnAddRecommendationToView != null) { OnAddRecommendationToView(cardData); } _currentlyShowing = true; }
private void OnCheckRecommendFlagSuccess(string json, BaseCardData baseCard) { if (json.Contains("false")) { RecommendationNotification recommendation = GetRecommendation(baseCard); if (null == recommendation) { throw new NullReferenceException("RecommendationController.OnCheckRecommendFlagSuccess - can't get card: " + baseCard.title); } recommendation.State = RecommendationState.NeedToShow; } }
private string GenerateSkillLabel(BaseCardData ddm) { string str = null; if (ddm.level_beginner) { str += (str != null) ? ", " : ""; str += HelperMethods.Instance.StringTable["level_beginner"]; } if (ddm.level_intermediate) { str += (str != null) ? ", " : ""; str += HelperMethods.Instance.StringTable["level_intermediate"]; } if (ddm.level_advanced) { str += (str != null) ? ", " : ""; str += HelperMethods.Instance.StringTable["level_advanced"]; } if (ddm.level_expert) { str += (str != null) ? ", " : ""; str += HelperMethods.Instance.StringTable["level_expert"]; } return str; }
public void OnCardDismissed(BaseCardData baseCard) { _model.RecommendationLogicController.OnDismissedCard(baseCard); }
public void OnRecommendButton(BaseCardData baseCard) { _model.RecommendationLogicController.OnRecommendButton(baseCard); }
private void AddRecommendationToView(BaseCardData cardData) { if (IsNotificationPresent() || null == cardData) return; GameObject notificationPrefabToMake = (GameObject) Resources.Load(PrefabPath + RecommendationPrefabName); if (null == notificationPrefabToMake) { Debug.LogError("Prefab " + RecommendationPrefabName + " could not be instantiated"); return; } if (!IsPanelActive()) { ActivatePanel(); } _model.RecommendationViewController = NGUITools.AddChild(_model.ParentForNatification.gameObject, notificationPrefabToMake) .GetComponent<RecommendationNotificationController>(); _model.RecommendationViewController.transform.localPosition = _startNotificationPos; _model.RecommendationViewController.Init(cardData); }
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"; }
public void Init(BaseCardData cardData) { //need to set the notification name _baseCard = cardData; _notificationModel.ActivitiesTitle.text = _baseCard.title; _notificationModel.RecommendedActiviteesTitle.text = _baseCard.title; _notificationModel.Id = cardData.id; }
private void OnCheckRecommendFlagSuccessFillData(string json, BaseCardData baseCard, int counter) { //Debug.Log("NotificationManager.OnCheckRecommendFlagSuccess - Activity: " + baseCard.nid + " name: " + baseCard.title); if ("{\"result\":[]}" == json) return; RecommendationNotification recommendation = GetRecommendation(baseCard); if (recommendation == null) { throw new NullReferenceException( "RecommendationController.OnCheckRecommendFlagSuccessFillData - cann't find activities: " + baseCard.title); } if (json.Contains("false")) { if (recommendation.State != RecommendationState.Skip && recommendation.State != RecommendationState.NeedToShow) recommendation.State = RecommendationState.NeedToShow; } else { recommendation.State = RecommendationState.Recommended; } int lastIndex = historyCardList.Count - 1; if (baseCard.id == historyCardList[lastIndex].id) { GetCardAndShowIt(); } }
public void Init(string title) { _baseCard = null; _notificationModel.ActivitiesTitle.text = title; _notificationModel.RecommendedActiviteesTitle.text = title; }
private string GenerateAudienceLabel(BaseCardData ddm) { string str = null; if (ddm.audience_kids) { str += (str != null) ? ", " : ""; str += HelperMethods.Instance.StringTable["audience_kids"]; } if (ddm.audience_teenagers) { str += (str != null) ? ", " : ""; str += HelperMethods.Instance.StringTable["audience_teenagers"]; } if (ddm.audience_adults) { str += (str != null) ? ", " : ""; str += HelperMethods.Instance.StringTable["audience_adults"]; } if (ddm.audience_seniors) { str += (str != null) ? ", " : ""; str += HelperMethods.Instance.StringTable["audience_seniors"]; } return str; }