i have 2 activities, one is a Database of exercises and the other one is new exercise creator
in this function i create a new class of an exercise, i want to return the new class to the Database activity.
and when creating a new exercise delete this activity and create a new one which will create a new Exercise class.
public void onClickDone(View view)
{
EditText editText = (EditText) findViewById(R.id.edit_name);
String name = editText.getText().toString();
editText = (EditText) findViewById(R.id.edit_description);
String description = editText.getText().toString();
editText = (EditText) findViewById(R.id.edit_reptitons);
EditText editSets = (EditText) findViewById(R.id.edit_sets);
EditText editTimeBetweenSets = (EditText) findViewById(R.id.edit_time_between_sets_);
int reptitons = 0 ;
int sets = 0 ;
int timeBetweenSets = 0;
try
{
reptitons = Integer.parseInt(editText.getText().toString());
sets = Integer.parseInt(editSets.getText().toString());
timeBetweenSets = Integer.parseInt(editTimeBetweenSets.getText().toString());
}
catch(NumberFormatException ex)
{
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
dlgAlert.setMessage("please check you input");
dlgAlert.setTitle("Wrong Input");
dlgAlert.setPositiveButton("OK", null);
dlgAlert.setCancelable(true);
dlgAlert.create().show();
}
_excercise = new Exercise(name, description, reptitons, sets, timeBetweenSets);
}
what is a the best practice for 2 activities to create a class, save it to a list and create a new one when pressing the "create new exercise button" again?
or maybe i should create the instance of the class inside the add exercise activity?