@@ -42,14 +42,14 @@ public class Cooking extends AppCompatActivity {
private ArrayList <List > directionList = new ArrayList <>();
//private ArrayList<MealItem> mealItems = new ArrayList<>();
private ArrayList <Step > allSteps = new ArrayList <Step >();
private Button btnNextStep ;
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client ;
public int counter = 10 ;
@ Override
protected void onCreate (Bundle savedInstanceState ) {
@@ -67,6 +67,23 @@ protected void onCreate(Bundle savedInstanceState) {
//updateMealList();
addAllSteps ();
final TextView timer = (TextView ) findViewById (R .id .timer );
final TextView previousStep = (TextView ) findViewById (R .id .previous_step );
final TextView currentStep = (TextView ) findViewById (R .id .current_step );
final TextView nextStep = (TextView ) findViewById (R .id .next_step );
//set previous step to nothing
previousStep .setText ("Previous Step" );
//set current step to first step
currentStep .setText ("Current Step" );
//set next step to next step
nextStep .setText ("Next Step" );
//set timer initial value
timer .setText ("00:00" );
//sets up the button and starts cooking
startCooking ();
/*
//directions
for (int i = 0; i < mealList.size(); i++) {
@@ -85,191 +102,251 @@ protected void onCreate(Bundle savedInstanceState) {
listViewSteps.setAdapter(adapterSteps);
*/
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient .Builder (this ).addApi (AppIndex .API ).build ();
}
public boolean onCreateOptionsMenu (Menu menu ) {
new MenuInflater (this ).inflate (R .menu .cancel , menu );
return (super .onCreateOptionsMenu (menu ));
}
@ Override
public boolean onOptionsItemSelected (MenuItem item ) {
switch (item .getItemId ()) {
case R .id .cancel :
// User chose the "Home" item, go to home
Intent intent = new Intent (getApplicationContext (), MainActivity .class );
setResult (Activity .RESULT_OK , intent );
startActivityForResult (intent , REQUEST_CODE_RECIPE_LIST );
//startActivity(new Intent(RecipeView.this, RecipeList.class));
return true ;
default :
// If we got here, the user's action was not recognized.
// Invoke the superclass to handle it.
return super .onOptionsItemSelected (item );
}
}
private int i = 0 ;
private int counter = 10 ;
private CountDownTimer timer1 ;
private void startCooking (){
btnNextStep = (Button ) findViewById (R .id .btnNextStep );
final TextView timer = (TextView ) findViewById (R .id .timer );
final TextView previousStep = (TextView ) findViewById (R .id .previous_step );
final TextView currentStep = (TextView ) findViewById (R .id .current_step );
final TextView nextStep = (TextView ) findViewById (R .id .next_step );
btnNextStep .setOnClickListener (new View .OnClickListener () {
public void onClick (View view ) {
counter = 10 ;
CountDownTimer timer1 = new CountDownTimer (10000 , 1000 ) {
//set button to say Next Step
btnNextStep .setText ("Cancel Timer" );
System .out .println ("______________________________________" );
System .out .println ("i: " + i );
System .out .println ("meal: " + allSteps .get (i ).getDescription ());
System .out .println ("time: " + i );
System .out .println ("______________________________________" );
//if first step
if (i == 0 ) {
//set previous step to nothing
previousStep .setText ("None" );
//set current step to first step
currentStep .setText (allSteps .get (i ).getDescription ());
//set next step to next step
nextStep .setText (allSteps .get (i + 1 ).getDescription ());
//if last step
} else if (i == (allSteps .size () - 1 )) {
//set previous step to nothing
previousStep .setText (allSteps .get (i - 1 ).getDescription ());
//set current step to first step
currentStep .setText (allSteps .get (i ).getDescription ());
//set next step to next step
nextStep .setText ("LAST STEP" );
} else {
previousStep .setText (allSteps .get (i - 1 ).getDescription ());
currentStep .setText (allSteps .get (i ).getDescription ());
nextStep .setText (allSteps .get (i + 1 ).getDescription ());
}
counter = allSteps .get (i ).getTime ();
timer1 = new CountDownTimer (counter * 1000 , 1000 ) {
public void onTick (long millisUntilFinished ) {
timer .setText (String .valueOf (counter ));
counter --;
}
public void onFinish () {
timer .setText ("FINISHED" );
i ++;
timer .setText ("Next Step" );
btnNextStep .setOnClickListener (new View .OnClickListener () {
public void onClick (View view ) {
startCooking ();
}
});
}
};
timer1 .start ();
}
});
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient .Builder (this ).addApi (AppIndex .API ).build ();
}
btnNextStep .setOnClickListener (new View .OnClickListener () {
public void onClick (View view ) {
timer1 .cancel ();
btnNextStep .setText ("Next Step" );
i ++;
//timer.setText("Cancel Timer");
startCooking ();
public boolean onCreateOptionsMenu (Menu menu ) {
new MenuInflater (this ).inflate (R .menu .cancel , menu );
return (super .onCreateOptionsMenu (menu ));
}
});
}
});
}
@ Override
public boolean onOptionsItemSelected (MenuItem item ) {
switch (item .getItemId ()) {
case R .id .cancel :
// User chose the "Home" item, go to home
Intent intent = new Intent (getApplicationContext (), MainActivity .class );
setResult (Activity .RESULT_OK , intent );
startActivityForResult (intent , REQUEST_CODE_RECIPE_LIST );
//startActivity(new Intent(RecipeView.this, RecipeList.class));
return true ;
default :
// If we got here, the user's action was not recognized.
// Invoke the superclass to handle it.
return super .onOptionsItemSelected (item );
}
}
//update Recipe List with new recipe
private void updateMealList () {
if (getIntent ().getParcelableArrayListExtra ("mealList" ) != null && !getIntent ().getParcelableArrayListExtra ("mealList" ).isEmpty ()) {
mealList = getIntent ().getParcelableArrayListExtra ("mealList" );
}
}
//update Recipe List with new recipe
private void updateMealList () {
if (getIntent ().getParcelableArrayListExtra ("mealList" ) != null && !getIntent ().getParcelableArrayListExtra ("mealList" ).isEmpty ()) {
mealList = getIntent ().getParcelableArrayListExtra ("mealList" );
}
}
/**
* add all the steps to the array in order they will go for making the recipe
*/
private void addAllSteps (){
String description ;
int time ;
String meal ;
Step temp ;
//NOT SURE IF THIS WILL REFERENCE TEMP AND CHANGE IT EACH TIME
//BLAKE CARTER LOOK AT THIS
//ALSO THIS IS HARD CODING HELL hahahahaha
meal = "Black Bean Hummus" ;
description = "first Step Description" ;
time = 10 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
meal = "Mexican Pasta" ;
description = "Second Step Description" ;
time = 20 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
meal = "French Orange Poached Pears" ;
description = "Thrid Step Description" ;
time = 30 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
meal = "Black Bean Hummus" ;
description = "Fourth Step Description" ;
time = 40 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
meal = "Mexican Pasta" ;
description = "Fifth Step Description" ;
time = 50 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
meal = "French Orange Poached Pears" ;
description = "Sixth Step Description" ;
time = 60 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
/**
* add all the steps to the array in order they will go for making the recipe
*/
private void addAllSteps (){
String description ;
int time ;
String meal ;
Step temp ;
//NOT SURE IF THIS WILL REFERENCE TEMP AND CHANGE IT EACH TIME
//BLAKE CARTER LOOK AT THIS
//ALSO THIS IS HARD CODING HELL hahahahaha
meal = "Black Bean Hummus" ;
description = "first Step Description" ;
time = 10 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
meal = "Mexican Pasta" ;
description = "Second Step Description" ;
time = 20 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
meal = "French Orange Poached Pears" ;
description = "Thrid Step Description" ;
time = 30 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
meal = "Black Bean Hummus" ;
description = "Fourth Step Description" ;
time = 40 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
meal = "Mexican Pasta" ;
description = "Fifth Step Description" ;
time = 50 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
meal = "French Orange Poached Pears" ;
description = "Sixth Step Description" ;
time = 60 ;
temp = new Step (meal , description , time );
allSteps .add (temp );
}
}
/**
* Set the directions for an individual recipe(meal item).
*
* @param recipeName
* @param quantity
*/
/*
/**
* Set the directions for an individual recipe(meal item).
*
* @param recipeName
* @param quantity
*/
/*
private MealItem setRecipeDirections(String recipeName, int quantity) {
MealItem meal = new MealItem();
if (recipeName.equals("Apple")) {
meal = new MealItem();
meal.addDirections("get apple");
meal.addDirections("wash apple");
meal.addDirections("cut apple");
meal.addDirections("put apple on plate");
meal.setQuantity(quantity);
meal.setRecipeName(recipeName);
} else if (recipeName.equals("banana")) {
meal = new MealItem();
meal.addDirections("get banana");
meal.addDirections("peel banana");
meal.addDirections("put banana in bowl");
meal.setQuantity(quantity);
meal.setRecipeName(recipeName);
} else if (recipeName.equals("grape")) {
meal = new MealItem();
meal.addDirections("pick grape");
meal.setQuantity(quantity);
meal.setRecipeName(recipeName);
} else {
System.out.println("WRONG RECIPE ENTERED FIX IT");
}
private MealItem setRecipeDirections(String recipeName, int quantity) {
MealItem meal = new MealItem();
if (recipeName.equals("Apple")) {
meal = new MealItem();
meal.addDirections("get apple");
meal.addDirections("wash apple");
meal.addDirections("cut apple");
meal.addDirections("put apple on plate");
meal.setQuantity(quantity);
meal.setRecipeName(recipeName);
} else if (recipeName.equals("banana")) {
meal = new MealItem();
meal.addDirections("get banana");
meal.addDirections("peel banana");
meal.addDirections("put banana in bowl");
meal.setQuantity(quantity);
meal.setRecipeName(recipeName);
} else if (recipeName.equals("grape")) {
meal = new MealItem();
meal.addDirections("pick grape");
meal.setQuantity(quantity);
meal.setRecipeName(recipeName);
} else {
System.out.println("WRONG RECIPE ENTERED FIX IT");
}
return meal;
}
*/
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
public Action getIndexApiAction () {
Thing object = new Thing .Builder ()
.setName ("Cooking Page" ) // TODO: Define a title for the content shown.
// TODO: Make sure this auto-generated URL is correct.
.setUrl (Uri .parse ("http://[ENTER-YOUR-URL-HERE]" ))
.build ();
return new Action .Builder (Action .TYPE_VIEW )
.setObject (object )
.setActionStatus (Action .STATUS_TYPE_COMPLETED )
.build ();
}
return meal;
}
*/
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
public Action getIndexApiAction () {
Thing object = new Thing .Builder ()
.setName ("Cooking Page" ) // TODO: Define a title for the content shown.
// TODO: Make sure this auto-generated URL is correct.
.setUrl (Uri .parse ("http://[ENTER-YOUR-URL-HERE]" ))
.build ();
return new Action .Builder (Action .TYPE_VIEW )
.setObject (object )
.setActionStatus (Action .STATUS_TYPE_COMPLETED )
.build ();
}
@ Override
public void onStart () {
super .onStart ();
@ Override
public void onStart () {
super .onStart ();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client .connect ();
AppIndex .AppIndexApi .start (client , getIndexApiAction ());
}
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client .connect ();
AppIndex .AppIndexApi .start (client , getIndexApiAction ());
}
@ Override
public void onStop () {
super .onStop ();
@ Override
public void onStop () {
super .onStop ();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
AppIndex .AppIndexApi .end (client , getIndexApiAction ());
client .disconnect ();
}
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
AppIndex .AppIndexApi .end (client , getIndexApiAction ());
client .disconnect ();
}
/*
private class MealItem {
ArrayList<String> directions;