本文整理汇总了Java中com.google.android.gms.games.Player类的典型用法代码示例。如果您正苦于以下问题:Java Player类的具体用法?Java Player怎么用?Java Player使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Player类属于com.google.android.gms.games包,在下文中一共展示了Player类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConnected
import com.google.android.gms.games.Player; //导入依赖的package包/类
/**
*
* Google API client
*
*/
@Override
public void onConnected( @Nullable Bundle bundle ) {
AIR.log( "GameServicesHelper | connected" );
if( mPendingAchievementsUI ) {
mPendingAchievementsUI = false;
showAchievementsUI();
} else if( mPendingLeaderboardsUI ) {
mPendingLeaderboardsUI = false;
showLeaderboardsUI( mPendingLeaderboardId );
} else {
AIR.log( "GameServicesHelper | user signed in" );
Player player = Games.Players.getCurrentPlayer( mGoogleApiClient );
JSONObject response = GSPlayerUtils.getJSON( player );
AIR.dispatchEvent( GameServicesEvent.AUTH_SUCCESS, response.toString() );
}
}
示例2: getJSON
import com.google.android.gms.games.Player; //导入依赖的package包/类
static JSONObject getJSON( Player player ) {
JSONObject response = new JSONObject();
if( player != null ) {
try {
response.put( "playerId", player.getPlayerId() );
response.put( "displayName", player.getDisplayName() );
if( player.hasIconImage() ) {
response.put( "iconImageUri", player.getIconImageUri().toString() );
}
if( player.hasHiResImage() ) {
response.put( "hiResImageUri", player.getHiResImageUri().toString() );
}
// alias not available
} catch( Exception e ) {
e.printStackTrace();
}
}
return response;
}
示例3: addUser
import com.google.android.gms.games.Player; //导入依赖的package包/类
private void addUser(website.bloop.app.api.Player player) {
SharedPreferences prefs = getSharedPreferences(BLOOP_PREFERENCE_FILE, Context.MODE_PRIVATE);
mApplication.getService().addPlayer(player)
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
responseBody -> {
String token = prefs.getString(BloopFirebaseInstanceIDService.PREF_FIREBASE_TOKEN, "");
if (token.equals("")) {
token = FirebaseInstanceId.getInstance().getToken();
}
mApplication.sendFirebaseRegistrationToServer(token);
},
throwable -> Log.e(TAG, throwable.getMessage())
);
}
示例4: showSignOutBar
import com.google.android.gms.games.Player; //导入依赖的package包/类
private void showSignOutBar() {
findViewById(R.id.sign_in_bar).setVisibility(View.GONE);
findViewById(R.id.sign_out_bar).setVisibility(View.VISIBLE);
Player player = Games.Players.getCurrentPlayer(mGoogleApiClient);
String url = player.getIconImageUrl();
TextView name = (TextView)findViewById(R.id.playerName);
name.setText(player.getDisplayName());
if (url != null) {
ImageView vw = (ImageView) findViewById(R.id.avatar);
// load the image in the background.
new DownloadImageTask(vw).execute(url);
}
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
TextView emailView = (TextView)findViewById((R.id.playerEmail));
emailView.setText(email);
}
示例5: d
import com.google.android.gms.games.Player; //导入依赖的package包/类
public d(LeaderboardScore paramLeaderboardScore)
{
this.vK = paramLeaderboardScore.getRank();
this.vL = ((String)eg.f(paramLeaderboardScore.getDisplayRank()));
this.vM = ((String)eg.f(paramLeaderboardScore.getDisplayScore()));
this.vN = paramLeaderboardScore.getRawScore();
this.vO = paramLeaderboardScore.getTimestampMillis();
this.vP = paramLeaderboardScore.getScoreHolderDisplayName();
this.vQ = paramLeaderboardScore.getScoreHolderIconImageUri();
this.vR = paramLeaderboardScore.getScoreHolderHiResImageUri();
Player localPlayer = paramLeaderboardScore.getScoreHolder();
PlayerEntity localPlayerEntity;
if (localPlayer == null)
localPlayerEntity = null;
else
localPlayerEntity = (PlayerEntity)localPlayer.freeze();
this.vS = localPlayerEntity;
this.vT = paramLeaderboardScore.getScoreTag();
}
示例6: ParticipantEntity
import com.google.android.gms.games.Player; //导入依赖的package包/类
public ParticipantEntity(Participant paramParticipant)
{
this.kg = 2;
this.up = paramParticipant.getParticipantId();
this.qa = paramParticipant.getDisplayName();
this.sL = paramParticipant.getIconImageUri();
this.sM = paramParticipant.getHiResImageUri();
this.wr = paramParticipant.getStatus();
this.ws = paramParticipant.dy();
this.wt = paramParticipant.isConnectedToRoom();
Player localPlayer = paramParticipant.getPlayer();
PlayerEntity localPlayerEntity;
if (localPlayer == null)
localPlayerEntity = null;
else
localPlayerEntity = new PlayerEntity(localPlayer);
this.wu = localPlayerEntity;
this.wv = paramParticipant.getCapabilities();
this.ww = paramParticipant.getResult();
}
示例7: scoresToJsonString
import com.google.android.gms.games.Player; //导入依赖的package包/类
private String scoresToJsonString( LeaderboardScoreBuffer scores ) {
int scoresNb = scores.getCount();
JSONArray jsonScores = new JSONArray();
for ( int i = 0; i < scoresNb; ++i ) {
LeaderboardScore score = scores.get(i);
JSONObject jsonScore = new JSONObject();
try {
jsonScore.put("value", score.getRawScore());
jsonScore.put("rank", score.getRank());
Player player = score.getScoreHolder();
JSONObject jsonPlayer = new JSONObject();
jsonPlayer.put("id", player.getPlayerId());
jsonPlayer.put("displayName", player.getDisplayName());
jsonPlayer.put("picture", player.getIconImageUri());
jsonScore.put("player", jsonPlayer);
jsonScores.put( jsonScore );
} catch( JSONException e ) {}
}
return jsonScores.toString();
}
示例8: call
import com.google.android.gms.games.Player; //导入依赖的package包/类
@Override
public FREObject call(FREContext arg0, FREObject[] arg1) {
Extension.context.createHelperIfNeeded(arg0.getActivity());
Player player = Games.Players.getCurrentPlayer(Extension.context.getApiClient());
FREObject playerName = null;
if (player != null)
{
try {
playerName = FREObject.newObject(player.getDisplayName());
} catch (FREWrongThreadException e) {
e.printStackTrace();
}
}
return playerName;
}
开发者ID:freshplanet,项目名称:ANE-Google-Play-Game-Services,代码行数:19,代码来源:AirGooglePlayGamesGetActivePlayerName.java
示例9: playerInfo
import com.google.android.gms.games.Player; //导入依赖的package包/类
private void playerInfo() {
Player player = fragmentController.getGamesClientPublic().getCurrentPlayer();
String name = player.getDisplayName();
Uri uri = player.getIconImageUri();
String displayName;
if (player == null) {
Log.w(TAG, "mGamesClient.getCurrentPlayer() is NULL!");
displayName = "???";
} else {
displayName = player.getDisplayName();
appPreference.setLoginName(displayName);
}
userInfo.setText(String.format(getString(R.string.you_are_signed_in_as), displayName));
//userIcon.setImageURI(uri);
}
示例10: playerInfo
import com.google.android.gms.games.Player; //导入依赖的package包/类
private void playerInfo() {
Player player = getGamesClient().getCurrentPlayer();
String name = player.getDisplayName();
Uri uri = player.getIconImageUri();
String displayName;
if (player == null) {
Log.w(TAG, "mGamesClient.getCurrentPlayer() is NULL!");
displayName = "???";
} else {
displayName = player.getDisplayName();
appPreference.setLoginName(displayName);
}
userInfo.setText(String.format(getString(R.string.you_are_signed_in_as), displayName));
//userIcon.setImageURI(uri);
}
示例11: ParticipantEntity
import com.google.android.gms.games.Player; //导入依赖的package包/类
public ParticipantEntity(Participant paramParticipant)
{
Player localPlayer = paramParticipant.i();
if (localPlayer == null);
for (PlayerEntity localPlayerEntity = null; ; localPlayerEntity = new PlayerEntity(localPlayer))
{
this.a = localPlayerEntity;
this.b = paramParticipant.h();
this.c = paramParticipant.e();
this.d = paramParticipant.f();
this.e = paramParticipant.g();
this.f = paramParticipant.b();
this.g = paramParticipant.c();
this.h = paramParticipant.d();
return;
}
}
示例12: onConnected
import com.google.android.gms.games.Player; //导入依赖的package包/类
@Override
public void onConnected(Bundle connectionHint)
{
// The player is signed in. Hide the sign-in button and allow the
// player to proceed.
Log.i("yoyo","Sign In Succeeded");
Player p = Games.Players.getCurrentPlayer(getApiClient());
String displayName;
String id;
if (p == null) {
Log.i("yoyo", "mGamesClient.getCurrentPlayer() is NULL!");
displayName = "???";
id="-1";
}
else {
displayName = p.getDisplayName();
id = p.getPlayerId();
}
Log.i("yoyo","Found displayname " + displayName + " with id " + id);
RunnerJNILib.OnLoginSuccess(displayName,id,"","","","","");
//Call back to generate the social event
}
示例13: succeedSignIn
import com.google.android.gms.games.Player; //导入依赖的package包/类
public void succeedSignIn() {
Log.d(TAG, "Google signed in.");
mAchievementsClient = Games.getAchievementsClient(activity, mAccount);
mLeaderboardsClient = Games.getLeaderboardsClient(activity, mAccount);
mPlayersClient = Games.getPlayersClient(activity, mAccount);
Games.getGamesClient(activity, mAccount).setViewForPopups(
activity.getWindow().getDecorView().findViewById(android.R.id.content));
GUtils.callScriptFunc("login", "true");
mPlayersClient.getCurrentPlayer()
.addOnCompleteListener(new OnCompleteListener<Player>() {
@Override
public void onComplete(@NonNull Task<Player> task) {
String displayName = "UserName";
if (task.isSuccessful()) {
displayName = task.getResult().getDisplayName();
} else {
Exception e = task.getException();
}
GUtils.callScriptFunc("user", displayName);
}
});
}
示例14: onConnected
import com.google.android.gms.games.Player; //导入依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {
Player p = Games.Players.getCurrentPlayer(mGoogleApiClient);
String displayName;
String playerId;
if (p == null) {
Log.w(TAG, "mGamesClient.getCurrentPlayer() is NULL!");
displayName = "???";
} else {
displayName = p.getDisplayName();
playerId = Games.Players.getCurrentPlayerId(mGoogleApiClient);
mApplication.setPlayerName(displayName);
mApplication.setPlayerId(playerId);
website.bloop.app.api.Player player = new website.bloop.app.api.Player(displayName, playerId, null);
addUser(player);
}
// hide button on login
loginButton.setVisibility(View.INVISIBLE);
loginText.setText(displayName);
// store that we are logged in
SharedPreferences pref = getSharedPreferences(PREF_LOGIN, Context.MODE_PRIVATE);
SharedPreferences.Editor ed = pref.edit();
ed.putBoolean(PREF_LOGIN_VAL, true);
ed.apply();
// start the main game now
Intent newIntent = new Intent(getBaseContext(), BloopActivity.class);
newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(newIntent);
finish();
}
示例15: updateGooglePlayGames
import com.google.android.gms.games.Player; //导入依赖的package包/类
private void updateGooglePlayGames() {
if (mGoogleApiClient.isConnected()) {
// Set the greeting appropriately on main menu
Player p = Games.Players.getCurrentPlayer(mGoogleApiClient);
String displayName;
Uri imageUri;
if (p == null) {
displayName = getString(R.string.google_play_games_player_unknown);
imageUri = null;
} else {
displayName = p.getDisplayName();
imageUri = p.hasHiResImage() ? p.getHiResImageUri() : p.getIconImageUri();
//bannerUri = p.getBannerImageLandscapeUri();
}
Log.w(TAG, "onConnected(): current player is " + displayName);
mIvGooglePlayGamesIcon.setVisibility(View.GONE);
mIvGooglePlayGamesAvatar.setVisibility(View.VISIBLE);
ImageManager.create(this).loadImage(mIvGooglePlayGamesAvatar, imageUri, R.drawable.im_avatar);
mTvGooglePlayGames.setVisibility(View.GONE);
mTvGooglePlayGamesName.setVisibility(View.VISIBLE);
mTvGooglePlayGamesName.setText(displayName);
mVgGooglePlayGamesActions.setVisibility(View.VISIBLE);
} else {
mIvGooglePlayGamesIcon.setVisibility(View.VISIBLE);
mIvGooglePlayGamesAvatar.setVisibility(View.GONE);
mTvGooglePlayGames.setVisibility(View.VISIBLE);
mTvGooglePlayGamesName.setVisibility(View.GONE);
mVgGooglePlayGamesActions.setVisibility(View.GONE);
}
}