package com.espritmobile.sim.restocheck.activities;

import java.math.BigDecimal;
import java.math.RoundingMode;

import com.espritmobile.sim.restocheck.MainActivity;
import com.espritmobile.sim.restocheck.R;
import com.espritmobile.sim.restocheck.entities.Plate;
import com.espritmobile.sim.restocheck.utils.Utils;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout.LayoutParams;

public class EqualActivity extends Activity {

	Button next;
	Button done;
	BigDecimal bill;
	Button plate_one, plate_two, plate_three, plate_four, plate_five,
			plate_six, plate_seven, plate_eight, plate_nine, plate_ten;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		final String price = Utils.price;
		bill = new BigDecimal(price);
		String res = bill.divide(new BigDecimal(Utils.count), 3,
				RoundingMode.CEILING) + Utils.currency;
		switch (Utils.count) {
		case 2:
			setContentView(R.layout.activity_equal_two);
			plate_one = (Button) findViewById(R.id.plate_one);
			plate_one.setText(res);
			plate_two = (Button) findViewById(R.id.plate_two);
			plate_two.setText(res);
			break;
		case 3:
			setContentView(R.layout.activity_equal_three);
			plate_one = (Button) findViewById(R.id.plate_one);
			plate_one.setText(res);
			plate_two = (Button) findViewById(R.id.plate_two);
			plate_two.setText(res);
			plate_three = (Button) findViewById(R.id.plate_three);
			plate_three.setText(res);

			break;
		case 4:
			setContentView(R.layout.activity_equal_four);
			plate_one = (Button) findViewById(R.id.plate_one);
			plate_one.setText(res);
			plate_two = (Button) findViewById(R.id.plate_two);
			plate_two.setText(res);
			plate_three = (Button) findViewById(R.id.plate_three);
			plate_three.setText(res);
			plate_four = (Button) findViewById(R.id.plate_four);
			plate_four.setText(res);
			break;
		case 5:
			setContentView(R.layout.activity_equal_five);
			plate_one = (Button) findViewById(R.id.plate_one);
			plate_one.setText(res);
			plate_two = (Button) findViewById(R.id.plate_two);
			plate_two.setText(res);
			plate_three = (Button) findViewById(R.id.plate_three);
			plate_three.setText(res);
			plate_four = (Button) findViewById(R.id.plate_four);
			plate_four.setText(res);
			plate_five = (Button) findViewById(R.id.plate_five);
			plate_five.setText(res);
			break;
		case 6:
			setContentView(R.layout.activity_equal_six);
			plate_one = (Button) findViewById(R.id.plate_one);
			plate_one.setText(res);
			plate_two = (Button) findViewById(R.id.plate_two);
			plate_two.setText(res);
			plate_three = (Button) findViewById(R.id.plate_three);
			plate_three.setText(res);
			plate_four = (Button) findViewById(R.id.plate_four);
			plate_four.setText(res);
			plate_five = (Button) findViewById(R.id.plate_five);
			plate_five.setText(res);
			plate_six = (Button) findViewById(R.id.plate_six);
			plate_six.setText(res);
			break;
		case 7:
			setContentView(R.layout.activity_equal_seven);
			plate_one = (Button) findViewById(R.id.plate_one);
			plate_one.setText(res);
			plate_two = (Button) findViewById(R.id.plate_two);
			plate_two.setText(res);
			plate_three = (Button) findViewById(R.id.plate_three);
			plate_three.setText(res);
			plate_four = (Button) findViewById(R.id.plate_four);
			plate_four.setText(res);
			plate_five = (Button) findViewById(R.id.plate_five);
			plate_five.setText(res);
			plate_six = (Button) findViewById(R.id.plate_six);
			plate_six.setText(res);
			plate_seven = (Button) findViewById(R.id.plate_seven);
			plate_seven.setText(res);
			break;
		case 8:
			setContentView(R.layout.activity_equal_eight);
			plate_one = (Button) findViewById(R.id.plate_one);
			plate_one.setText(res);
			plate_two = (Button) findViewById(R.id.plate_two);
			plate_two.setText(res);
			plate_three = (Button) findViewById(R.id.plate_three);
			plate_three.setText(res);
			plate_four = (Button) findViewById(R.id.plate_four);
			plate_four.setText(res);
			plate_five = (Button) findViewById(R.id.plate_five);
			plate_five.setText(res);
			plate_six = (Button) findViewById(R.id.plate_six);
			plate_six.setText(res);
			plate_seven = (Button) findViewById(R.id.plate_seven);
			plate_seven.setText(res);
			plate_eight = (Button) findViewById(R.id.plate_eight);
			plate_eight.setText(res);
			break;
		case 9:
			setContentView(R.layout.activity_equal_nine);
			plate_one = (Button) findViewById(R.id.plate_one);
			plate_one.setText(res);
			plate_two = (Button) findViewById(R.id.plate_two);
			plate_two.setText(res);
			plate_three = (Button) findViewById(R.id.plate_three);
			plate_three.setText(res);
			plate_four = (Button) findViewById(R.id.plate_four);
			plate_four.setText(res);
			plate_five = (Button) findViewById(R.id.plate_five);
			plate_five.setText(res);
			plate_six = (Button) findViewById(R.id.plate_six);
			plate_six.setText(res);
			plate_seven = (Button) findViewById(R.id.plate_seven);
			plate_seven.setText(res);
			plate_eight = (Button) findViewById(R.id.plate_eight);
			plate_eight.setText(res);
			plate_nine = (Button) findViewById(R.id.plate_nine);
			plate_nine.setText(res);
			break;
		case 10:
			setContentView(R.layout.activity_equal_ten);
			plate_one = (Button) findViewById(R.id.plate_one);
			plate_one.setText(res);
			plate_two = (Button) findViewById(R.id.plate_two);
			plate_two.setText(res);
			plate_three = (Button) findViewById(R.id.plate_three);
			plate_three.setText(res);
			plate_four = (Button) findViewById(R.id.plate_four);
			plate_four.setText(res);
			plate_five = (Button) findViewById(R.id.plate_five);
			plate_five.setText(res);
			plate_six = (Button) findViewById(R.id.plate_six);
			plate_six.setText(res);
			plate_seven = (Button) findViewById(R.id.plate_seven);
			plate_seven.setText(res);
			plate_eight = (Button) findViewById(R.id.plate_eight);
			plate_eight.setText(res);
			plate_nine = (Button) findViewById(R.id.plate_nine);
			plate_nine.setText(res);
			plate_ten = (Button) findViewById(R.id.plate_ten);
			plate_ten.setText(res);
			break;
		default:
			break;
		}
		done = (Button) findViewById(R.id.done);
		done.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				startActivity(new Intent(EqualActivity.this, MainActivity.class));
				overridePendingTransition(R.anim.slide_in_right,
						R.anim.slide_out_left);
				finish();

			}
		});
		next = (Button) findViewById(R.id.next);
		next.setText(price + Utils.currency);
		next.setClickable(false);

	}

}