GameUtilMain.java :  » Game » bgg-android-tools » com » sigmazero13 » gameutils » Android Open Source

Android Open Source » Game » bgg android tools 
bgg android tools » com » sigmazero13 » gameutils » GameUtilMain.java
package com.sigmazero13.gameutils;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class GameUtilMain extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    Button pickButton = (Button)this.findViewById(R.id.button_pick_game);
    pickButton.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        Intent i = new Intent(GameUtilMain.this, GamePickerConfig.class);
        startActivityForResult(i, 0);
      }
    });
    
    Button recordButton = (Button)this.findViewById(R.id.button_record_play);
    recordButton.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        Toast.makeText(GameUtilMain.this, "Not yet implemented...", Toast.LENGTH_SHORT).show();
      }
    });
    
    Button listButton = (Button)this.findViewById(R.id.button_view_games);
    listButton.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        Intent i = new Intent(GameUtilMain.this, GameList.class);
        startActivity(i);
      }
    });
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);
    return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
    case R.id.preferences:
      Intent i = new Intent(GameUtilMain.this, GamePreferences.class);
      startActivity(i);
      break;
    }
    
    return true;
  }
  
  @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
        super.onActivityResult(requestCode, resultCode, intent);
        
        switch (resultCode) {
        case RESULT_OK:
          Intent i = new Intent(GameUtilMain.this, GamePickerResult.class);
          i.putExtra("num_players", intent.getExtras().getInt("num_players"));
          i.putExtra("max_length", intent.getExtras().getInt("max_length"));
          startActivity(i);
          break;
          
        }
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.