com.google.android.gms.games.multiplayer.OnInvitationReceivedListener Java Examples

The following examples show how to use com.google.android.gms.games.multiplayer.OnInvitationReceivedListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GameServicesHelper.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onSignInSucceeded() {
    achievements = new GoogleAchievements(activity, helper.getApiClient());
    cloudSave = new GoogleCloudSave(activity, helper.getApiClient());
    multiplayer = new GameServicesMultiplayer(activity, helper.getApiClient(), helper.getInvitation());
    Games.Invitations
        .loadInvitations(helper.getApiClient())
        .setResultCallback(new ResultCallback<Invitations.LoadInvitationsResult>() {
            @Override public void onResult(final Invitations.LoadInvitationsResult result) {
                if (multiplayer == null) return;
                multiplayer.loadInvitations(result.getInvitations());
            }
        });
    invitationListenerRegistered = true;
    Games.Invitations.registerInvitationListener(helper.getApiClient(), new OnInvitationReceivedListener() {
        @Override public void onInvitationReceived(final Invitation invitation) {
            if (multiplayer == null) return;
            multiplayer.onInvitationReceived(invitation);
        }

        @Override public void onInvitationRemoved(final String s) {
            if (multiplayer == null) return;
            multiplayer.onInvitationRemoved(s);
        }
    });
    Gdx.app.postRunnable(new Runnable() {
        @Override public void run() {
            dispatcher.setState(ServicesState.CONNECTED);
        }
    });
}