Android Open Source - PowerGridCompanion Player Setup






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;
//w  w  w  .j a va2  s.  co  m
import android.app.Activity;
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 android.widget.ListView;
import android.widget.Toast;

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

import java.util.ArrayList;
import java.util.List;

public class PlayerSetup extends Activity {

    public ArrayList<Player> playerList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_player_setup_view);
        playerList = new ArrayList<Player>();
        Bundle extras = getIntent().getExtras();
        if(extras != null){

            if (extras.containsKey("PlayerList")) {
                playerList = extras.getParcelableArrayList("PlayerList");
            }

        }


        this.getActionBar().setTitle("Setting up " + playerList.size() + " Players");

        ListView lv = (ListView)findViewById(R.id.SetupListView);
        lv.setAdapter(new PlayerSetupAdapter(this,R.id.SetupListView,playerList));

    }


    @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_setup, menu);
        return true;
    }


    public void FinishedSetup(final View v){

        for(Player p : playerList){
            if(p.getColor() == Color.GRAY){
                Toast.makeText(this,"Please Finish Setup!",Toast.LENGTH_LONG).show();
                return;
            }
        }

        Intent mainIntent = new Intent(v.getContext(), TurnOrderSummary.class);

        Bundle extras = new Bundle();
        //TODO: Make init values shared pref according to settings
        extras.putInt("Coal",24);
        extras.putInt("Oil",18);
        extras.putInt("Garbage",6);
        extras.putInt("Uranium",2);
        extras.putInt("Stage",0);
        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