@Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    switch (id) {
      case R.id.action_rate:
        this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.app_url)));
        return true;
      case R.id.action_leaderboard:
        if (BuildConfig.DEBUG || mGoogleApiClient.isConnected()) {
          startActivity(new Intent(getApplicationContext(), LeaderboardActivity.class));
        } else {
          mGoogleApiClient.connect();
        }
        return true;
      case R.id.action_achievements:
        if (BuildConfig.DEBUG) {
          return true;
        }

        if (mGoogleApiClient.isConnected()) {
          startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient), 5);
        } else {
          mGoogleApiClient.connect();
        }
        return true;
    }

    return super.onOptionsItemSelected(item);
  }
Example #2
0
 public void showAchievements() {
   if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
     startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient), 2);
   } else if (mGoogleApiClient != null) {
     mGoogleApiClient.connect();
   }
 }
 @Override
 public void unlockAchievementGPGS(String achievementId) {
   if (this.gameHelper.isSignedIn()) {
     Games.Achievements.unlock(this.gameHelper.getApiClient(), achievementId);
   } else if (!this.gameHelper.isConnecting()) {
     this.loginGPGS();
     return;
   }
 }
 @Override
 public void getAchievementsGPGS() {
   if (this.gameHelper.isSignedIn()) {
     this.startActivityForResult(
         Games.Achievements.getAchievementsIntent(this.gameHelper.getApiClient()), 101);
   } else if (!this.gameHelper.isConnecting()) {
     this.loginGPGS();
     return;
   }
 }
 @Override
 public void showAchievement() {
   if (isSignedIn() == true) {
     startActivityForResult(
         Games.Achievements.getAchievementsIntent(myApp.getClient()),
         requestCode); // , getString(R.string.achievement_dum_dum)
   } else {
     signIn();
   }
 }
  public void processAchievements() {
    int score = game.getScore();

    if (score > 0) {
      Games.Achievements.unlock(mGoogleApiClient, Constants.achievement_boom);
      // Score level achievements
      Games.Achievements.increment(
          mGoogleApiClient, Constants.achievement_just_getting_started, score);
      Games.Achievements.increment(
          mGoogleApiClient, Constants.achievement_established_starter, score);
      Games.Achievements.increment(mGoogleApiClient, Constants.achievement_seasoned_pro, score);
      Games.Achievements.increment(mGoogleApiClient, Constants.achievement_grizzly_veteran, score);
      Games.Achievements.increment(mGoogleApiClient, Constants.achievement_gridiron_legend, score);
      Games.Achievements.increment(
          mGoogleApiClient, Constants.achievement_never_gonna_give_your_up, score);
    }

    if (controller.hadWrongAnswer()) {
      Games.Achievements.unlock(mGoogleApiClient, Constants.achievement_oops);
    }

    if (controller.getBestStreak() >= 3) {
      Games.Achievements.unlock(mGoogleApiClient, Constants.achievement_tictactoe);
    }

    if (controller.getLongestWrongStreak() >= 3) {
      Games.Achievements.unlock(mGoogleApiClient, Constants.achievement_tictacouch);
    }

    if (controller.getStartStreak() >= 10) {
      Games.Achievements.unlock(mGoogleApiClient, Constants.achievement_jumping_the_snap_count);
    }
  }
Example #7
0
 public void unlockAchievement(int achi) {
   String achievement = getString(achi);
   if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
     Games.Achievements.unlock(mGoogleApiClient, achievement);
   }
 }
Example #8
0
 @Override
 public void getAchievementsGPGS() {
   startActivityForResult(
       Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), ACHIEVEMENTS_REQUEST);
 }
Example #9
0
 @Override
 public void unlockAchievementGPGS(String achievementId) {
   Games.Achievements.unlock(gameHelper.getApiClient(), achievementId);
 }
Example #10
0
 @Override
 public void unlockAchievement(String achievementId) {
   if (isSignedIn() == true) Games.Achievements.unlock(_gameHelper.getApiClient(), achievementId);
 }