Android Open Source - square-libgdx Main Activity






From Project

Back to project page square-libgdx.

License

The source code is released under:

GNU General Public License

If you think the Android project square-libgdx 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 com.realcode.square;
/* w ww .j  a  v a 2 s .co m*/
import android.app.Dialog;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.denzyldick.square.SquareMain;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;

public class MainActivity extends AndroidApplication {

  private static final String AD_UNIT_ID = "ca-app-pub-7086272485798980/4787146654";
  private static final String GOOGLE_PLAY_URL = "https://play.google.com/store/apps/developer?id=RealCode";
  protected AdView adView;
  protected View gameView;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
    cfg.useGL20 = true;
    cfg.useAccelerometer = false;
    cfg.useCompass = false;
    initialize(new SquareMain(), cfg);
    // Do the stuff that initialize() would do for you
    /* requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

    RelativeLayout layout = new RelativeLayout(this);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    layout.setLayoutParams(params);

    AdView admobView = createAdView();
    layout.addView(admobView);
    View gameView = createGameView(cfg);
    layout.addView(gameView);

    setContentView(layout);
    startAdvertising(admobView); */
  }

  private AdView createAdView() {
    adView = new AdView(this);
    adView.setAdSize(AdSize.SMART_BANNER);
    adView.setAdUnitId(AD_UNIT_ID);
    adView.setId(12345); // this is an arbitrary id, allows for relative positioning in createGameView()
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    adView.setLayoutParams(params);
    adView.setBackgroundColor(Color.BLACK);
    return adView;
  }

  private View createGameView(AndroidApplicationConfiguration cfg) {
    gameView = initializeForView(new SquareMain(), cfg);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.BELOW, adView.getId());
    gameView.setLayoutParams(params);
    return gameView;
  }

  private void startAdvertising(AdView adView) {
    AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);
  }
  
  @Override
  public void onResume() {
    super.onResume();
    if (adView != null) adView.resume();
  }

  @Override
  public void onPause() {
    if (adView != null) adView.pause();
    super.onPause();
  }

  @Override
  public void onDestroy() {
    if (adView != null) adView.destroy();
    super.onDestroy();
  }

  
}




Java Source Code List

actors.Square.java
com.denzyldick.square.Assets.java
com.denzyldick.square.BackgroundAnimation.java
com.denzyldick.square.File.java
com.denzyldick.square.Font.java
com.denzyldick.square.Main.java
com.denzyldick.square.SoundManager.java
com.denzyldick.square.SquareMain.java
com.denzyldick.square.StarManagement.java
com.denzyldick.square.client.GwtLauncher.java
com.denzyldick.square.json.JsonArray.java
com.denzyldick.square.json.JsonLiteral.java
com.denzyldick.square.json.JsonNumber.java
com.denzyldick.square.json.JsonObject.java
com.denzyldick.square.json.JsonParser.java
com.denzyldick.square.json.JsonString.java
com.denzyldick.square.json.JsonValue.java
com.denzyldick.square.json.JsonWriter.java
com.denzyldick.square.json.ParseException.java
com.realcode.square.MainActivity.java
screens.GameMenu.java
screens.GameScreen.java
screens.LostScreen.java
screens.MenuScreen.java
screens.OptionsScreen.java
screens.SplashScreen.java
screens.TutorialScreen.java
screens.WonScreen.java