Android Open Source - CatchDROP Android Launcher






From Project

Back to project page CatchDROP.

License

The source code is released under:

GNU General Public License

If you think the Android project CatchDROP listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package projects.nerdybuzz.catchdrop.android;
//from  w  w w.  j a va  2 s  .  c o m
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;

import projects.nerdybuzz.catchdrop.CDGame;
import projects.nerdybuzz.catchdrop.googleservices.IGoogleServices;

import com.google.android.gms.games.Games;
import com.google.example.games.basegameutils.*;
import com.google.example.games.basegameutils.GameHelper.GameHelperListener;

public class AndroidLauncher extends AndroidApplication implements IGoogleServices {
  private GameHelper _gameHelper;
  private final static int REQUEST_CODE_UNUSED = 9002;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    _gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
    _gameHelper.enableDebugLog(false);

    GameHelperListener gameHelperListener = new GameHelper.GameHelperListener()
    {
      @Override
      public void onSignInSucceeded() {
      }
  
      @Override
      public void onSignInFailed() {
      }
    };

    _gameHelper.setup(gameHelperListener);
    
    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
    config.useAccelerometer = false;
    config.useCompass = false;
    initialize(new CDGame(this, "Touch", false), config);
  }

  @Override
  public void signIn() {
    try {
      runOnUiThread(new Runnable() {
        //@Override
        public void run() {
          _gameHelper.beginUserInitiatedSignIn();
        }
      });
    } catch (Exception e) {
      Gdx.app.log("AndroidLauncher", "Log in failed: " + e.getMessage() + ".");
    }
  }

  @Override
  public void signOut() {
    try {
      runOnUiThread(new Runnable() {
        //@Override
        public void run() {
          _gameHelper.signOut();
        }
      });
    } catch (Exception e) {
      Gdx.app.log("AndroidLauncher", "Log out failed: " + e.getMessage() + ".");
    }
  }

  @Override
  public void rateGame() {
    String str ="https://play.google.com/store/apps/details?id=projects.nerdybuzz.catchdrop";
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
  }

  @Override
  public void submitClassicScore(long score) {
    if (isSignedIn() == true) {
      Games.Leaderboards.submitScore(_gameHelper.getApiClient(), getString(R.string.chs_leaderboard_id), score);
      startActivityForResult(Games.Leaderboards.getLeaderboardIntent(_gameHelper.getApiClient(), getString(R.string.chs_leaderboard_id)), REQUEST_CODE_UNUSED);
    } else {
      // Maybe sign in here then redirect to submitting score?
    }
  }
  
  @Override
  public void submitZenScore(long score) {
    if (isSignedIn() == true) {
      Games.Leaderboards.submitScore(_gameHelper.getApiClient(), getString(R.string.zhs_leaderboard_id), score);
      startActivityForResult(Games.Leaderboards.getLeaderboardIntent(_gameHelper.getApiClient(), getString(R.string.zhs_leaderboard_id)), REQUEST_CODE_UNUSED);
    } else {
      // Maybe sign in here then redirect to submitting score?
    }
  }

  @Override
  public void showClassicScores() {
    if (isSignedIn() == true)
      startActivityForResult(Games.Leaderboards.getLeaderboardIntent(_gameHelper.getApiClient(), getString(R.string.chs_leaderboard_id)), REQUEST_CODE_UNUSED);
    else {
      signIn();
      if (isSignedIn() == true)
        startActivityForResult(Games.Leaderboards.getLeaderboardIntent(_gameHelper.getApiClient(), getString(R.string.chs_leaderboard_id)), REQUEST_CODE_UNUSED);
    }
  }
  
  @Override
  public void showZenScores() {
    if (isSignedIn() == true)
      startActivityForResult(Games.Leaderboards.getLeaderboardIntent(_gameHelper.getApiClient(), getString(R.string.zhs_leaderboard_id)), REQUEST_CODE_UNUSED);
    else {
      signIn();
      if (isSignedIn() == true)
        startActivityForResult(Games.Leaderboards.getLeaderboardIntent(_gameHelper.getApiClient(), getString(R.string.zhs_leaderboard_id)), REQUEST_CODE_UNUSED);
    }
  }

  @Override
  public boolean isSignedIn() {
    return _gameHelper.isSignedIn();
  }
  
  @Override
  protected void onStart() {
    super.onStart();
    _gameHelper.onStart(this);
  }

  @Override
  protected void onStop() {
    super.onStop();
    _gameHelper.onStop();
  }

  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    _gameHelper.onActivityResult(requestCode, resultCode, data);
  }
}




Java Source Code List

android.UnusedStub.java
com.google.example.games.basegameutils.BaseGameActivity.java
com.google.example.games.basegameutils.BaseGameUtils.java
com.google.example.games.basegameutils.GameHelperUtils.java
com.google.example.games.basegameutils.GameHelper.java
projects.nerdybuzz.catchdrop.BurntToastObj.java
projects.nerdybuzz.catchdrop.CDGame.java
projects.nerdybuzz.catchdrop.ClassicGame.java
projects.nerdybuzz.catchdrop.EndScreen.java
projects.nerdybuzz.catchdrop.FallingAct.java
projects.nerdybuzz.catchdrop.FallingRect.java
projects.nerdybuzz.catchdrop.GameScreen.java
projects.nerdybuzz.catchdrop.KeySequence.java
projects.nerdybuzz.catchdrop.MainMenuScreen.java
projects.nerdybuzz.catchdrop.PoisonDrop.java
projects.nerdybuzz.catchdrop.SettingsScreen.java
projects.nerdybuzz.catchdrop.TimePowerUp.java
projects.nerdybuzz.catchdrop.ZenGame.java
projects.nerdybuzz.catchdrop.android.AndroidLauncher.java
projects.nerdybuzz.catchdrop.client.HtmlLauncher.java
projects.nerdybuzz.catchdrop.desktop.AppletLauncher.java
projects.nerdybuzz.catchdrop.desktop.DesktopLauncher.java
projects.nerdybuzz.catchdrop.googleservices.DesktopGoogleServices.java
projects.nerdybuzz.catchdrop.googleservices.IGoogleServices.java