internal void AddSuggestedApps( MainWindow ParentWindow, List <AppRecommendation> suggestedApps, int clientShowCount) { int appPosition = 1; int appRank = 1; ParentWindow.mWelcomeTab.mHomeAppManager.ClearAppRecommendationPool(); foreach (AppRecommendation suggestedApp in suggestedApps) { if (!ParentWindow.mAppHandler.IsAppInstalled(suggestedApp.ExtraPayload["click_action_packagename"])) { RecommendedApps recomApp = new RecommendedApps(); recomApp.Populate(suggestedApp, appPosition, appRank); if (appPosition <= clientShowCount) { this.mAppRecommendationsPanel.Children.Add((UIElement)recomApp); ++appPosition; } else { ParentWindow.mWelcomeTab.mHomeAppManager.AddToAppRecommendationPool(recomApp); } } ++appRank; } }
private void SendAppRecommendationsImpressionStats() { JArray jarray = new JArray(); RecommendedAppsSection child1 = this.mAppRecommendationSectionsPanel.Children[0] as RecommendedAppsSection; for (int index = 0; index < child1.mAppRecommendationsPanel.Children.Count; ++index) { RecommendedApps child2 = child1.mAppRecommendationsPanel.Children[index] as RecommendedApps; JObject jobject = new JObject() { { "app_loc", (JToken)(child2.AppRecomendation.ExtraPayload["click_generic_action"] == "InstallCDN" ? "cdn" : "gplay") }, { "app_pkg", (JToken)child2.AppRecomendation.ExtraPayload["click_action_packagename"] }, { "is_installed", (JToken)(this.ParentWindow.mAppHandler.IsAppInstalled(child2.AppRecomendation.ExtraPayload["click_action_packagename"]) ? "true" : "false") }, { "app_position", (JToken)child2.RecommendedAppPosition.ToString((IFormatProvider)CultureInfo.InvariantCulture) }, { "app_rank", (JToken)child2.RecommendedAppRank.ToString((IFormatProvider)CultureInfo.InvariantCulture) } }; jarray.Add((JToken)jobject); } ClientStats.SendFrontendClickStats("apps_recommendation", "impression", (string)null, (string)null, (string)null, (string)null, (string)null, jarray.ToString(Formatting.None)); }
internal void AddToAppRecommendationPool(RecommendedApps recomApp) { this.mHomeApp?.sAppRecommendationsPool.Add(recomApp); }
internal void UpdateRecommendedAppsInstallStatus(string package) { if (this.mAppRecommendationSectionsPanel.Children.Count <= 0) { return; } int index1 = -1; RecommendedAppsSection child1 = this.mAppRecommendationSectionsPanel.Children[0] as RecommendedAppsSection; RecommendedApps recommendedApps1 = (RecommendedApps)null; for (int index2 = 0; index2 < child1.mAppRecommendationsPanel.Children.Count; ++index2) { RecommendedApps child2 = child1.mAppRecommendationsPanel.Children[index2] as RecommendedApps; if (child2.AppRecomendation.AppPackage.Equals(package, StringComparison.InvariantCultureIgnoreCase)) { index1 = index2; recommendedApps1 = child2; break; } } if (index1 == -1) { return; } child1.mAppRecommendationsPanel.Children.RemoveAt(index1); if (this.sAppRecommendationsPool.Count > 0) { int count = 1; for (int index2 = 0; index2 < this.sAppRecommendationsPool.Count; ++index2) { RecommendedApps recommendedApps2 = this.sAppRecommendationsPool[index2]; if (!this.ParentWindow.mAppHandler.IsAppInstalled(recommendedApps2.AppRecomendation.ExtraPayload["click_action_packagename"])) { recommendedApps2.RecommendedAppPosition = recommendedApps1.RecommendedAppPosition; child1.mAppRecommendationsPanel.Children.Insert(index1, (UIElement)recommendedApps2); JArray jarray = new JArray(); JObject jobject1 = new JObject(); jobject1.Add("app_loc", (JToken)(recommendedApps2.AppRecomendation.ExtraPayload["click_generic_action"] == "InstallCDN" ? "cdn" : "gplay")); jobject1.Add("app_pkg", (JToken)recommendedApps2.AppRecomendation.ExtraPayload["click_action_packagename"]); jobject1.Add("is_installed", (JToken)(this.ParentWindow.mAppHandler.IsAppInstalled(recommendedApps2.AppRecomendation.ExtraPayload["click_action_packagename"]) ? "true" : "false")); int num = recommendedApps2.RecommendedAppPosition; jobject1.Add("app_position", (JToken)num.ToString((IFormatProvider)CultureInfo.InvariantCulture)); num = recommendedApps2.RecommendedAppRank; jobject1.Add("app_rank", (JToken)num.ToString((IFormatProvider)CultureInfo.InvariantCulture)); JObject jobject2 = jobject1; jarray.Add((JToken)jobject2); ClientStats.SendFrontendClickStats("apps_recommendation", "impression", (string)null, (string)null, (string)null, (string)null, (string)null, jarray.ToString(Formatting.None)); break; } ++count; } this.sAppRecommendationsPool.RemoveRange(0, count); } if (child1.mAppRecommendationsPanel.Children.Count == 0) { this.mAppRecommendationSectionsPanel.Children.Remove((UIElement)child1); } if (this.mAppRecommendationSectionsPanel.Children.Count != 0) { return; } this.mAppRecommendationSectionsPanel.Visibility = Visibility.Collapsed; this.mAppRecommendationsGenericMessages.Visibility = Visibility.Visible; }