Android Open Source - AndroidSettlers Main






From Project

Back to project page AndroidSettlers.

License

The source code is released under:

GNU General Public License

If you think the Android project AndroidSettlers 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.settlers.hd;
//from w w w .  j ava 2s. c  o m
import java.util.Vector;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Main extends Activity {

  private static final String DONATE_URL = "https://www.paypal.com/cgi-bin/"
      + "webscr?cmd=_donations&business=isaac.neil@gmail.com&"
      + "item_name=Island+Settlers+donation&no_shipping=1";

  private Vector<Runnable> actions;

  @Override
  public void onResume() {
    super.onResume();

    Board board = ((Settlers) getApplicationContext()).getBoardInstance();
    Settings settings = ((Settlers) getApplicationContext()).getSettingsInstance();

    Vector<String> labels = new Vector<String>();
    actions = new Vector<Runnable>();

    if (board != null && board.getWinner(settings) == null) {
      labels.add(getString(R.string.resume_button));
      actions.add(new Runnable() {
        @Override
        public void run() {
          Main.this.startActivity(new Intent(Main.this, GameActivity.class));
        }
      });
    }

    labels.add(getString(R.string.new_button));
    actions.add(new Runnable() {
      @Override
      public void run() {
        Main.this.startActivity(new Intent(Main.this, LocalGame.class));
      }
    });

    labels.add(getString(R.string.stats));
    actions.add(new Runnable() {
      @Override
      public void run() {
        Main.this.startActivity(new Intent(Main.this, Stats.class));
      }
    });

    labels.add(getString(R.string.rules_button));
    actions.add(new Runnable() {
      @Override
      public void run() {
        Main.this.startActivity(new Intent(Main.this, Rules.class));
      }
    });

    labels.add(getString(R.string.about_button));
    actions.add(new Runnable() {
      @Override
      public void run() {
        final Builder aboutDialog = new AlertDialog.Builder(Main.this);
        aboutDialog.setTitle(R.string.app_name);
        aboutDialog.setIcon(R.drawable.icon);
        aboutDialog.setMessage(getString(R.string.about_text) + "\n\n" + getString(R.string.acknowledgements)
            + "\n\n" + getString(R.string.translators));
        aboutDialog.show();
      }
    });

    labels.add(getString(R.string.site_button));
    actions.add(new Runnable() {
      @Override
      public void run() {
        Main.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.website_url))));
      }
    });

    labels.add(getString(R.string.donate_button));
    actions.add(new Runnable() {
      @Override
      public void run() {
        Main.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(DONATE_URL)));
      }
    });

    String[] values = new String[labels.size()];
    for (int i = 0; i < values.length; i++)
      values[i] = labels.get(i);

    int padding = (int) (10 * getResources().getDisplayMetrics().density);

    ListView view = new ListView(this);
    view.setPadding(padding, padding, padding, padding);

    view.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, values));

    view.setOnItemClickListener(new OnItemClickListener() {
      @Override
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        actions.get(position).run();
      }
    });

    setContentView(view);
  }
}




Java Source Code List

com.settlers.hd.AcceptTrade.java
com.settlers.hd.AutomatedPlayer.java
com.settlers.hd.BalancedAI.java
com.settlers.hd.Board.java
com.settlers.hd.CounterOffer.java
com.settlers.hd.Discard.java
com.settlers.hd.Edge.java
com.settlers.hd.GameActivity.java
com.settlers.hd.GameRenderer.java
com.settlers.hd.GameView.java
com.settlers.hd.Geometry.java
com.settlers.hd.Hexagon.java
com.settlers.hd.LocalGame.java
com.settlers.hd.Main.java
com.settlers.hd.PlayerTrade.java
com.settlers.hd.Player.java
com.settlers.hd.Reference.java
com.settlers.hd.ResourceView.java
com.settlers.hd.Rules.java
com.settlers.hd.Settings.java
com.settlers.hd.Settlers.java
com.settlers.hd.Square.java
com.settlers.hd.Stats.java
com.settlers.hd.Status.java
com.settlers.hd.TextureManager.java
com.settlers.hd.Trader.java
com.settlers.hd.UIButton.java
com.settlers.hd.Vertex.java