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); } }
@Override public void onSignInSucceeded() { super.onSignInSucceeded(); signInLayout.setVisibility(View.GONE); achievementsButton.setVisibility(View.VISIBLE); leaderboardsButton.setVisibility(View.VISIBLE); signedUserLayout.setVisibility(View.VISIBLE); Player currentPlayer = Games.Players.getCurrentPlayer(getApiClient()); signOutAlertDialog.setMessage(getString(R.string.sign_out_message, currentPlayer.getDisplayName())); signedUserTextView.setText(currentPlayer.getDisplayName()); if (!isUserPhoto(signedUserImageView.getDrawable())) ImageManager.create(this).loadImage(signedUserImageView, currentPlayer.getIconImageUri()); }
@Inject public AvatarManager(Context context) { imageManager = ImageManager.create(context); }
private void loadUserImage(ImageView view, Participant participant) { if (participant.getIconImageUri() != null) { ImageManager.create(getActivity()).loadImage(view, participant.getIconImageUri()); } }
public void gserviceInvitationReceived(final Uri imagesrc, final String username, final String invitationId) { final AlertDialog.Builder alert = new AlertDialog.Builder(this); final LayoutInflater inflater = this.getLayoutInflater(); runOnUiThread(new Runnable() { @Override public void run() { final View myView = inflater.inflate(R.layout.dialog_invitation, null); alert.setView(myView).setTitle("Invitation received").setCancelable(false).setNegativeButton("Decline", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Games.RealTimeMultiplayer.declineInvitation(gHelper.getApiClient(), invitationId); } }); alert.setPositiveButton("Accept", null); final AlertDialog d = alert.create(); d.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface arg0) { ImageManager im = ImageManager.create(getApplicationContext()); im.loadImage(((ImageView)myView.findViewById(R.id.image)), imagesrc); TextView tv = (TextView)myView.findViewById(R.id.text); tv.setText(username + " wants to play with you..."); tv.setFocusable(true); tv.setFocusableInTouchMode(true); tv.requestFocus(); Button b = d.getButton(AlertDialog.BUTTON_POSITIVE); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { _gserviceAcceptInvitation(invitationId); d.dismiss(); } }); } }); d.show(); } }); }