package credit.android.dg;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.graphics.drawable.shapes.RoundRectShape;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

public class Profile extends Activity {
	private TextView m_tvMessages;
	private View[] m_vPerks;
	private ShapeDrawable m_sdTopShape;
	private ShapeDrawable m_sdBottomShape;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.profile);
		
		m_tvMessages = (TextView) findViewById(R.id.profile_messages);
		m_tvMessages.setOnClickListener(new View.OnClickListener(){
			public void onClick(View view){
				doMessage();
			}
		});
		
		m_vPerks = new View[4];
		m_vPerks[0] = findViewById(R.id.perk_1);
		m_vPerks[3] = findViewById(R.id.perk_4);
		
		makeTopRounded();
		makeBottomRounded();
		
		m_vPerks[0].setOnClickListener(new View.OnClickListener(){
			public void onClick(View view){
				doTradeArea(0);
			}
		});
		
		/*
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.header);
		((TextView) findViewById(R.id.header_text)).setText("PROFILE");
		
		TestListView = (ListView) findViewById(R.id.test_list);
		TestListView.setOnItemClickListener(new OnItemClickListener(){
		
			public void onItemClick(AdapterView<?> l, View v, int position, long id) {
				// TODO Auto-generated method stub

			}
		});*/
	}
	
	public void doMessage(){
		Intent i = new Intent(this, Message.class);
		startActivity(i);
	}
	
	public void doTradeArea(int value){
		Intent i = new Intent(this, TradeArea.class);
		i.putExtra(Constants.PERK_NUMBER_STRING, value);
		startActivity(i);
	}
	
	public void makeTopRounded(){
		float[] outerR = new float[] { 8, 8, 8, 8, 0, 0, 0, 0 };
		m_sdTopShape = new ShapeDrawable(new RoundRectShape(outerR, null, null));
		m_sdTopShape.getPaint().setColor(0xffffffff);
		m_vPerks[0].setBackgroundDrawable(m_sdTopShape);
	};
	
	public void makeBottomRounded(){
		float[] outerR = new float[] { 0, 0, 0, 0, 8, 8, 8, 8 };
		m_sdBottomShape = new ShapeDrawable(new RoundRectShape(outerR, null, null));
		m_sdBottomShape.getPaint().setColor(0xffffffff);
		m_vPerks[m_vPerks.length - 1].setBackgroundDrawable(m_sdBottomShape);
	};
}
