Android Open Source - PowerGridCompanion Player Selection






From Project

Back to project page PowerGridCompanion.

License

The source code is released under:

Apache License

If you think the Android project PowerGridCompanion 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.mintcode.kris.powergridhelper.Activities;
/*from   www . j  ava2s. c  o m*/
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.mintcode.kris.powergridhelper.R;
import com.mintcode.kris.powergridhelper.Models.Player;

import java.util.ArrayList;

public class PlayerSelection extends Activity {

    public ArrayList<Player> playerList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_player_selection);
        getActionBar().setTitle("Player Selection");
    }


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




    public void play(final View v){

        playerList = new ArrayList<Player>();

        if(R.id.two == v.getId()){
            Intent mainIntent = new Intent(v.getContext(), PlayerSetup.class);

            playerList.add(new Player("Player 1", Color.GRAY));
            playerList.add(new Player("Player 2",Color.GRAY));

            Bundle extras = new Bundle();
            extras.putInt("PlayerNum", 2);
            extras.putParcelableArrayList("PlayerList", playerList);
            mainIntent.putExtras(extras);

            startActivity(mainIntent);
        }

        if(R.id.three == v.getId()){
            Intent mainIntent = new Intent(v.getContext(), PlayerSetup.class);

            playerList.add(new Player("Player 1", Color.GRAY));
            playerList.add(new Player("Player 2",Color.GRAY));
            playerList.add(new Player("Player 3",Color.GRAY));

            Bundle extras = new Bundle();
            extras.putInt("PlayerNum", 3);
            extras.putParcelableArrayList("PlayerList", playerList);
            mainIntent.putExtras(extras);

            startActivity(mainIntent);
        }

        if(R.id.four == v.getId()){
            Intent mainIntent = new Intent(v.getContext(), PlayerSetup.class);

            playerList.add(new Player("Player 1", Color.GRAY));
            playerList.add(new Player("Player 2",Color.GRAY));
            playerList.add(new Player("Player 3",Color.GRAY));
            playerList.add(new Player("Player 4",Color.GRAY));


            Bundle extras = new Bundle();
            extras.putInt("PlayerNum", 4);
            extras.putParcelableArrayList("PlayerList", playerList);
            mainIntent.putExtras(extras);

            startActivity(mainIntent);
        }

        if(R.id.five == v.getId()){
            Intent mainIntent = new Intent(v.getContext(), PlayerSetup.class);

            playerList.add(new Player("Player 1", Color.GRAY));
            playerList.add(new Player("Player 2",Color.GRAY));
            playerList.add(new Player("Player 3",Color.GRAY));
            playerList.add(new Player("Player 4", Color.GRAY));
            playerList.add(new Player("Player 5",Color.GRAY));


            Bundle extras = new Bundle();
            extras.putInt("PlayerNum", 5);
            extras.putParcelableArrayList("PlayerList", playerList);
            mainIntent.putExtras(extras);

            startActivity(mainIntent);
        }

        if(R.id.six == v.getId()){
            Intent mainIntent = new Intent(v.getContext(), PlayerSetup.class);

            playerList.add(new Player("Player 1", Color.GRAY));
            playerList.add(new Player("Player 2",Color.GRAY));
            playerList.add(new Player("Player 3",Color.GRAY));
            playerList.add(new Player("Player 4", Color.GRAY));
            playerList.add(new Player("Player 5",Color.GRAY));
            playerList.add(new Player("Player 6",Color.GRAY));

            Bundle extras = new Bundle();
            extras.putInt("PlayerNum", 6);
            extras.putParcelableArrayList("PlayerList", playerList);
            mainIntent.putExtras(extras);

            startActivity(mainIntent);
        }



    }
}




Java Source Code List

com.mintcode.kris.powergridhelper.Activities.BuildingActivity.java
com.mintcode.kris.powergridhelper.Activities.PlayerSelection.java
com.mintcode.kris.powergridhelper.Activities.PlayerSetup.java
com.mintcode.kris.powergridhelper.Activities.PowerPlantAuctionActivity.java
com.mintcode.kris.powergridhelper.Activities.ResourcePurchaseActivity.java
com.mintcode.kris.powergridhelper.Activities.StartScreen.java
com.mintcode.kris.powergridhelper.Activities.TurnOrderSummary.java
com.mintcode.kris.powergridhelper.Adapters.BuildingAdapter.java
com.mintcode.kris.powergridhelper.Adapters.PlayerOrderAdapter.java
com.mintcode.kris.powergridhelper.Adapters.PlayerSetupAdapter.java
com.mintcode.kris.powergridhelper.Adapters.PowerPlantAdapter.java
com.mintcode.kris.powergridhelper.Adapters.ResourceAdapter.java
com.mintcode.kris.powergridhelper.Models.Player.java