Android Open Source - TokenTracker Randomizer Activity






From Project

Back to project page TokenTracker.

License

The source code is released under:

GNU General Public License

If you think the Android project TokenTracker 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.ekflagristoj.tokentracker;
//from ww  w . j  a v a  2  s .c  o  m
import com.ekflagristoj.tokentracker.util.Randomizer;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.NumberPicker;
import android.widget.TextView;

public class RandomizerActivity extends Activity {

  private Randomizer rnd = new Randomizer();
  
  private TextView lblResult;
  private NumberPicker sidesPicker;
  private String[] sidesOptions = { "4", "6", "8", "10", "12", "20", "100" };
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_randomizer);
    lblResult = (TextView)findViewById( R.id.lblResult );
    sidesPicker = (NumberPicker)findViewById( R.id.sidesPicker );
    sidesPicker.setMinValue( 0 );
    sidesPicker.setMaxValue( (sidesOptions.length - 1) );
    sidesPicker.setValue( 5 );
    sidesPicker.setDisplayedValues( sidesOptions );
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_randomizer, menu);
    return true;
  }

  public void flipCoin( View v ) {
    String result = rnd.flipCoin();
    if ( result == "h" ) {
      lblResult.setText( (CharSequence)"Heads" );
    } else {
      lblResult.setText( (CharSequence)"Tails" );
    }
  }
  public void rollDie( View v ) {
    int faces;
    faces = Integer.parseInt( sidesOptions[ sidesPicker.getValue() ] );
    if ( faces >= 2 ) {
      Integer result = rnd.rollDie( faces );
      lblResult.setText( (CharSequence)result.toString() );
    }
  }
  public void done( View v ) {
    Intent intobj = new Intent( RandomizerActivity.this, MainActivity.class );
    startActivity( intobj );
  }
}




Java Source Code List

com.ekflagristoj.tokentracker.CreatePlayerActivity.java
com.ekflagristoj.tokentracker.CreateTokenActivity.java
com.ekflagristoj.tokentracker.MainActivity.java
com.ekflagristoj.tokentracker.RandomizerActivity.java
com.ekflagristoj.tokentracker.SpawnTokenActivity.java
com.ekflagristoj.tokentracker.util.Card.java
com.ekflagristoj.tokentracker.util.DatabaseHelper.java
com.ekflagristoj.tokentracker.util.Player.java
com.ekflagristoj.tokentracker.util.Randomizer.java
com.ekflagristoj.tokentracker.util.TokenDataSource.java
com.ekflagristoj.tokentracker.util.Token.java