protected override void OnAppearing() { if (FacebookAuth.isFBAuthenticated()) { var jsonResponse = ""; Task getUserInfo = new Task(() => { jsonResponse = FacebookAPI.getUserInfo().Result; }); getUserInfo.Start(); getUserInfo.Wait(); if (jsonResponse.Length > 0) { JObject o = JObject.Parse(jsonResponse); new Firebase().updateScore(o.GetValue("id").ToString(), new HighscoreEntry { name = o.GetValue("name").ToString(), sumDistance = App.sumDistance, sumQuestions = App.sumQuestions, sumGames = App.sumGames }); } } }
protected override void OnAppearing() { base.OnAppearing(); if (App.sumQuestions > 0) { LblAvgDeviation.Text = string.Format("Avg. Deviation: {0:0.00}km", (App.sumDistance / App.sumQuestions)); LblQuestionCount.Text = string.Format("Questions: {0:0}", App.sumQuestions); LblGameCount.Text = string.Format("Games: {0:0}", App.sumGames); } if (FacebookAuth.isFBAuthenticated()) { var jsonResponse = ""; Task getUserInfo = new Task(() => { jsonResponse = FacebookAPI.getUserInfo().Result; }); getUserInfo.Start(); getUserInfo.Wait(); if (jsonResponse.Length > 0) { JObject o = JObject.Parse(jsonResponse); LblUser.Text = o.GetValue("name").ToString(); } } else { LblUser.Text = "Guest"; } var highscoreEntries = new Firebase().getHighscoreEntries(); List <String> items = new List <string>(); foreach (KeyValuePair <String, HighscoreEntry> pair in highscoreEntries) { double avgDeviation = pair.Value.sumDistance / pair.Value.sumQuestions; items.Add("#" + (items.Count + 1) + " " + pair.Value.name + ": " + string.Format("{0:0.00}km", avgDeviation)); } listViewHighscore.ItemsSource = items.ToArray(); if (FacebookAuth.isFBAuthenticated()) { BtnLogin.Text = "Logout"; BtnLogin.Clicked += Logout_Clicked; BtnLogin.Clicked -= Login_Clicked; } }