Android Open Source - AndroidSettlers Rules






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;
//  w ww  .j a  v a2 s .c  om
import java.io.ByteArrayOutputStream;
import java.io.InputStream;

import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.webkit.WebView;

public class Rules extends Activity {
  @Override
  public void onCreate(Bundle state) {
    super.onCreate(state);

    setContentView(R.layout.rules);
    setTitle(R.string.rules_button);

    ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    String data = null;

    try {
      InputStream is = getResources().openRawResource(R.raw.rules);

      byte[] buffer = new byte[4096];
      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      while (true) {
        int read = is.read(buffer);
        if (read == -1)
          break;

        baos.write(buffer, 0, read);
      }

      baos.close();
      is.close();

      data = baos.toString();
    } catch (Exception e) {
      Log.e(this.getClass().getName(), "failed to load resource to string", e);
    }

    final WebView rules = (WebView) findViewById(R.id.rules);
    rules.loadData(data != null ? data : getString(R.string.rules_failed), "text/html", "utf-8");
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
      finish();
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
}




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