public void ShowUI(string leaderboardId, UM_LeaderboardTimeSpan timeSpan, Action <SA_Result> callback)
        {
            AN_Leaderboard.TimeSpan span = AN_Leaderboard.TimeSpan.AllTime;

            switch (timeSpan)
            {
            case UM_LeaderboardTimeSpan.AllTime:
                span = AN_Leaderboard.TimeSpan.AllTime;
                break;

            case UM_LeaderboardTimeSpan.Daily:
                span = AN_Leaderboard.TimeSpan.Daily;
                break;

            case UM_LeaderboardTimeSpan.Weekly:
                span = AN_Leaderboard.TimeSpan.Weekly;
                break;
            }

            var client = AN_Games.GetLeaderboardsClient();

            client.GetLeaderboardIntent(leaderboardId, span, (result) => {
                if (result.IsSucceeded)
                {
                    var intent             = result.Intent;
                    AN_ProxyActivity proxy = new AN_ProxyActivity();
                    proxy.StartActivityForResult(intent, (intentResult) => {
                        proxy.Finish();
                        callback.Invoke(intentResult);
                    });
                }
                else
                {
                    callback.Invoke(result);
                }
            });
        }
        public void LoadCurrentPlayerScore(string leaderboardId, UM_LeaderboardTimeSpan span, UM_LeaderboardCollection collection, Action <UM_ScoreLoadResult> callback)
        {
            var leaderboards = AN_Games.GetLeaderboardsClient();


            AN_Leaderboard.TimeSpan an_timeSpan = AN_Leaderboard.TimeSpan.AllTime;
            switch (span)
            {
            case UM_LeaderboardTimeSpan.AllTime:
                an_timeSpan = AN_Leaderboard.TimeSpan.AllTime;
                break;

            case UM_LeaderboardTimeSpan.Weekly:
                an_timeSpan = AN_Leaderboard.TimeSpan.Weekly;
                break;

            case UM_LeaderboardTimeSpan.Daily:
                an_timeSpan = AN_Leaderboard.TimeSpan.Daily;
                break;
            }

            AN_Leaderboard.Collection an_collection = AN_Leaderboard.Collection.Public;
            switch (collection)
            {
            case UM_LeaderboardCollection.Public:
                an_collection = AN_Leaderboard.Collection.Public;
                break;

            case UM_LeaderboardCollection.Social:
                an_collection = AN_Leaderboard.Collection.Social;
                break;
            }



            leaderboards.LoadCurrentPlayerLeaderboardScore(leaderboardId, an_timeSpan, an_collection, (res) => {
                UM_ScoreLoadResult um_result;
                if (res.IsSucceeded)
                {
                    AN_LeaderboardScore an_score = res.Data;

                    int context;
                    try {
                        context = Convert.ToInt32(an_score.ScoreTag);
                    } catch (Exception ex) {
                        Debug.LogWarning("Failed to convert anroid score tag to int. leaderboardId: " + leaderboardId + " error: " + ex.Message);
                        context = 0;
                    }

                    UM_Score score = new UM_Score(an_score.RawScore,
                                                  an_score.Rank,
                                                  context,
                                                  an_score.TimestampMillis);

                    um_result = new UM_ScoreLoadResult(score);
                }
                else
                {
                    um_result = new UM_ScoreLoadResult(res.Error);
                }

                callback.Invoke(um_result);
            });
        }
 /// <summary>
 /// Retrieves the <see cref="Result"/> object for the given time span, if any.
 /// </summary>
 public Result GetScoreResult(AN_Leaderboard.TimeSpan timeSpan)
 {
     return(AN_GMS_Lib.Leaderboards.ScoreSubmissionData_GetScoreResult(this, (int)timeSpan));
 }
 /// <summary>
 /// Asynchronously loads <see cref="AN_LeaderboardScore"/> result
 /// that represents the signed-in player's score for the leaderboard specified by leaderboardId.
 /// </summary>
 /// <param name="leaderboardId">The ID of the leaderboard to view.</param>
 /// <param name="span">Time span to retrieve data for. </param>
 /// <param name="leaderboardCollection">The collection to show by default. </param>
 /// <param name="callback">Request async callback</param>
 public void LoadCurrentPlayerLeaderboardScore(string leaderboardId, AN_Leaderboard.TimeSpan span, AN_Leaderboard.Collection leaderboardCollection, Action <AN_LinkedObjectResult <AN_LeaderboardScore> > callback)
 {
     AN_GMS_Lib.Leaderboards.LoadCurrentPlayerLeaderboardScore(this, leaderboardId, (int)span, (int)leaderboardCollection, callback);
 }
 /// <summary>
 /// Asynchronously loads an Intent to show a leaderboard for a game specified by a leaderboardId.
 /// Note that the Intent returned from the Task must be invoked with <see cref="App.AN_Activity.StartActivityForResult(Content.AN_Intent, Action{App.AN_ActivityResult})"/>,
 /// so that the identity of the calling package can be established.
 /// </summary>
 /// <param name="leaderboardId">The ID of the leaderboard to view.</param>
 /// <param name="span">Time span to retrieve data for. </param>
 /// <param name="leaderboardCollection">The collection to show by default. </param>
 /// <param name="callback">Request async callback</param>
 public void GetLeaderboardIntent(string leaderboardId, AN_Leaderboard.TimeSpan span, AN_Leaderboard.Collection leaderboardCollection, Action <AN_IntentResult> callback)
 {
     AN_GMS_Lib.Leaderboards.GetLeaderboardIntent(this, leaderboardId, (int)span, (int)leaderboardCollection, callback);
 }
 /// <summary>
 /// Asynchronously loads an Intent to show a leaderboard for a game specified by a leaderboardId.
 /// Note that the Intent returned from the Task must be invoked with <see cref="App.AN_Activity.StartActivityForResult(Content.AN_Intent, Action{App.AN_ActivityResult})"/>,
 /// so that the identity of the calling package can be established.
 /// </summary>
 /// <param name="leaderboardId">The ID of the leaderboard to view.</param>
 /// <param name="span">Time span to retrieve data for. </param>
 /// <param name="callback">Request async callback</param>
 public void GetLeaderboardIntent(string leaderboardId, AN_Leaderboard.TimeSpan span, Action <AN_IntentResult> callback)
 {
     GetLeaderboardIntent(leaderboardId, span, AN_Leaderboard.Collection.Public, callback);
 }
 /// <summary>
 /// Asynchronously loads an <see cref="AN_LeaderboardScores"/> that represents represents the top page of scores
 /// for a given leaderboard specified by specified by <see cref="leaderboardId"/>.
 /// If the player does not have a score on this leaderboard, this call will return the top page instead.
 /// </summary>
 /// <param name="leaderboardId">ID of the leaderboard.</param>
 /// <param name="span">Time span to retrieve data for.</param>
 /// <param name="leaderboardCollection">The leaderboard collection to retrieve scores for.</param>
 /// <param name="maxResults">The maximum number of scores to fetch per page. Must be between 1 and 25.</param>
 /// <param name="forceReload">
 /// If <c>true</c>, this call will clear any locally cached data and attempt to fetch the latest data from the server.
 /// This would commonly be used for something like a user-initiated refresh.
 /// Normally, this should be set to <c>false</c> to gain advantages of data caching.
 /// </param>
 /// <param name="callback">Request async callback</param>
 public void LoadTopScores(string leaderboardId, AN_Leaderboard.TimeSpan span, AN_Leaderboard.Collection leaderboardCollection, int maxResults, bool forceReload, Action <AN_LinkedObjectResult <AN_LeaderboardScores> > callback)
 {
     AN_GMS_Lib.Leaderboards.LoadTopScores(this, leaderboardId, (int)span, (int)leaderboardCollection, maxResults, forceReload, callback);
 }