package credit.android.dg;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class TradeArea extends Activity{
	
	private View v1;
	private TextView t1;
	private Button i1;
	private TextView[] Upgrades;
	
	private int mPerkNumber;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.trade_area);
		
		resolveExtras(savedInstanceState);
		
		t1 = (TextView) findViewById(R.id.upgrade_1_price);
		i1 = (Button) findViewById(R.id.button_upgrade_1);
		Upgrades = new TextView[6];
		Upgrades[0] = (TextView) findViewById(R.id.upgrade_1_text);
		Upgrades[1] = (TextView) findViewById(R.id.upgrade_2_text);
		Upgrades[2] = (TextView) findViewById(R.id.upgrade_3_text);
		Upgrades[3] = (TextView) findViewById(R.id.upgrade_4_text);
		Upgrades[4] = (TextView) findViewById(R.id.upgrade_5_text);
		Upgrades[5] = (TextView) findViewById(R.id.upgrade_6_text);
		
		for (int i=0;i<6;i++){
			Upgrades[i].setText(Constants.UPGRADES[mPerkNumber][i]);
		}
		
		v1 = findViewById(R.id.upgrade_1);
		v1.setOnClickListener(new View.OnClickListener(){
			public void onClick(View view){
				t1.setVisibility(View.VISIBLE);
				//i1.setImageResource(R.drawable.btn_green);
				
				for (int i=0;i<6;i++){
					Upgrades[i].setText(Constants.UPGRADES[mPerkNumber+1][i]);
				}
			}
		});
	}
	
	public void resolveExtras(Bundle bundle){
		Bundle extras = getIntent().getExtras();
		mPerkNumber = bundle != null ? bundle.getInt(Constants.PERK_NUMBER_STRING) : 0;
		if (mPerkNumber == 0){			
			mPerkNumber = extras != null ? extras.getInt(Constants.PERK_NUMBER_STRING) : 0;
		}
	}

}
