Ejemplo n.º 1
0
        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
                    });
                }
            }
        }
Ejemplo n.º 2
0
 void Share_Handle_Clicked(object sender, System.EventArgs e)
 {
     if (FacebookAuth.isFBAuthenticated())
     {
         FacebookAPI.createPost(string.Format("I just played a few rounds Linz Geo Quiz and got an average deviation of {0:0.00}km!!!111 Come and check it out too :-)", avgDev));
     }
 }
Ejemplo n.º 3
0
        void Logout_Clicked(object sender, System.EventArgs e)
        {
            FacebookAuth.logout();

            BtnLogin.Text     = "Login with Facebook";
            BtnLogin.Clicked -= Logout_Clicked;
            BtnLogin.Clicked += Login_Clicked;
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
 void Login_Clicked(object sender, System.EventArgs e)
 {
     FacebookAuth.authenticateFacebook(Navigation);
 }