Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added showLeaderboardUI #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Added function for displaying default leaderboard UI https://developers.google.com/games/services/android/leaderboards

AirGooglePlayGames.getInstance().showLeaderboardUI(LEADERBOARD_ID); //display leaderboard by id
AirGooglePlayGames.getInstance().showLeaderboardUI(); // display all leaderboards



Air Native Extension for Google Play Games Services (Android)
======================================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ package com.freshplanet.ane.AirGooglePlayGames
if (AirGooglePlayGames.isSupported)
_context.call("getLeaderboard", leaderboardId );
}

public function showLeaderboardUI( leaderboardId:String ):void
{
if (AirGooglePlayGames.isSupported)
_context.call("showLeaderboardUI", leaderboardId );
}

// --------------------------------------------------------------------------------------//
// //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.freshplanet.googleplaygames.functions.AirGooglePlayGamesSignInFunction;
import com.freshplanet.googleplaygames.functions.AirGooglePlayGamesSignOutFunction;
import com.freshplanet.googleplaygames.functions.AirGooglePlayStartAtLaunch;
import com.freshplanet.googleplaygames.functions.AirGooglePlayGamesShowLeaderboardUIFuction;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.games.Games;
import com.google.android.gms.games.Player;
Expand Down Expand Up @@ -70,6 +71,8 @@ public Map<String, FREFunction> getFunctions()
functionMap.put("showStandardAchievements", new AirGooglePlayGamesShowAchievementsFunction());
functionMap.put("getActivePlayerName", new AirGooglePlayGamesGetActivePlayerName());
functionMap.put("getLeaderboard", new AirGooglePlayGamesGetLeaderboardFunction());
functionMap.put("showLeaderboardUI", new AirGooglePlayGamesShowLeaderboardUIFuction());

return functionMap;
}

Expand Down Expand Up @@ -159,7 +162,7 @@ public void reportScore(String leaderboardId, int highScore)
}

public void getLeaderboard( String leaderboardId ) {

Games.Leaderboards.loadTopScores(
getApiClient(),
leaderboardId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@


package com.freshplanet.googleplaygames.functions;

import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.adobe.fre.FREObject;
import com.google.android.gms.games.Games;
import com.freshplanet.googleplaygames.GameHelper;
import com.freshplanet.googleplaygames.Extension;


public class AirGooglePlayGamesShowLeaderboardUIFuction implements FREFunction {

@Override
public FREObject call(FREContext arg0, FREObject[] arg1) {
String leaderboardId = null;
try
{
leaderboardId = arg1[0].getAsString();
}
catch (Exception e)
{
e.printStackTrace();
return null;
}


if( leaderboardId != null ) {
arg0.getActivity().startActivityForResult(Games.Leaderboards.getLeaderboardIntent(Extension.context.getApiClient(),leaderboardId), GameHelper.RC_UNUSED);
}else{
arg0.getActivity().startActivityForResult(Games.Leaderboards.getAllLeaderboardsIntent(Extension.context.getApiClient()), GameHelper.RC_UNUSED);
}


return null;

}

}
Binary file modified bin/AirGooglePlayGameServices.ane
Binary file not shown.