package be.kuleuven.VTKfakbarCWA1.view.sales.Action;
import be.kuleuven.VTKfakbarCWA1.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
/**
* This class is in charge of making a newPrice rule
* @author Niels
*
*/
public class ActionRuleNewPrice extends Activity{
private EditText mEditTextRuleChangePrice;
private String mActionRuleChangePrice;
private String NewPrice = "newPrice";
private OnClickListener mActionNewPriceClickListener = new OnClickListener(){
public void onClick(View v) {
mActionRuleChangePrice = mEditTextRuleChangePrice.getText().toString();
Bundle bundle = new Bundle();
Intent mIntent = new Intent();
if (v.getId() == R.id.actionNewPriceOk){
bundle.putString(NewPrice, mActionRuleChangePrice);
mIntent.putExtras(bundle);
setResult(RESULT_OK, mIntent);
finish();
}
if(v.getId() == R.id.newPriceCancel){
bundle.putString(NewPrice,null);
mIntent.putExtras(bundle);
setResult(RESULT_CANCELED, mIntent);
finish();
}
}
};
/**
* This method is first called when created. It initializes all the buttons.
*/
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.actionnewprice);
Button buttonCancel = (Button)findViewById(R.id.newPriceCancel);
buttonCancel.setOnClickListener(mActionNewPriceClickListener);
mEditTextRuleChangePrice = (EditText)findViewById(R.id.ruleMerchandisePrice);
Button buttonOk = (Button)findViewById(R.id.actionNewPriceOk);
buttonOk.setOnClickListener(mActionNewPriceClickListener);
}
/**
* This method overrides the return bottom. This is to be certain that te method won't crash if it doesn't get a return.
*/
public void onBackPressed() {
Bundle bundle = new Bundle();
Intent i = new Intent();
bundle.putString(NewPrice,null);
i.putExtras(bundle);
setResult(RESULT_CANCELED, i);
finish();
return;
}
}
|