package com.hello.hegberg.warondemand;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

public class ViewChangeProduct extends AppCompatActivity {
    /* Depending on which button is clicked to get here the view will be different.
     if it came from view, edit, delete, then it will go to a list of items and when
     you click on a product is will either view, edit, or delete the product.
     If add had been clicked, then it will go to a view to insert a product. */

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if(MainActivity.productOption == 1) {
            setContentView(R.layout.activity_view_products);
            //ViewProducts();
            //uncomment above line when function fixed
        }
        if(MainActivity.productOption == 2) {
            setContentView(R.layout.activity_add_products);
            //AddProducts();
            //uncomment above line when function fixed
        }
        if(MainActivity.productOption == 3) {
            setContentView(R.layout.activity_edit_products);
            //EditProducts();
            //uncomment above line when function fixed
        }
        if(MainActivity.productOption == 4) {
            setContentView(R.layout.activity_delete_products);
            //deleteProducts();
            //uncomment above line when function fixed
        }

    }

    /*
    //commented out since bad code
    public void ViewProducts() {
        setContentView(R.layout.activity_view_products);


        Button back = (Button) findViewById(R.id.back);//instead of a back button
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(AddEditAccount.this, MyProduct.class));


            }
        });

    }
    public void AddProducts() {

        Button edit = (Button) findViewById(R.id.add);
        Button back = (Button) findViewById(R.id.back);//instead of a back button
        add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //json change

            }
        });
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(AddEditAccount.this, MyProduct.class));

            }
        });

    }
    public void EditProducts() {
        //TODO: Prompt user to input info, check user input for unique username info,
        // and add button to commit it to Json.
        Button confirm = (Button) findViewById(R.id.confirm);
        Button cancel = (Button) findViewById(R.id.cancel);//instead of a back button
        confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //connect to json and delete product from record
            }
        });
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(AddEditAccount.this, MyProduct.class));

            }
        });

    }
    public void DeleteProducts() {
        //TODO: Prompt user to input info, check user input for unique username info,
        // and add button to commit it to Json.
        Button confirm = (Button) findViewById(R.id.confirm);
        Button cancel = (Button) findViewById(R.id.cancel);//instead of a back button
        confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               // connect to Json and delete product from record
            }
        });
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //TODO: return to my product
            }
        });
    }
    */





}

@@ -138,38 +138,9 @@
 ew;%0A
-import android.widget.Button;
 %0A
+
 %0Apub
@@ -1461,49 +1461,10 @@
  %7D%0A%0A
-    /*%0A    //commented out since bad code
+/*
 %0A   
@@ -1751,32 +1751,80 @@
 Click(View v) %7B%0A
+                MainActivity.productOption = 0;%0A
                 
@@ -1844,37 +1844,40 @@
 (new Intent(
-AddEditAccoun
+ViewChangeProduc
 t.this, MyPr
@@ -1899,32 +1899,33 @@
 %0A%0A            %7D%0A
+%0A
         %7D);%0A%0A   
@@ -2009,19 +2009,20 @@
 Id(R.id.
-add
+edit
 );%0A     
@@ -2214,32 +2214,80 @@
 Click(View v) %7B%0A
+                MainActivity.productOption = 0;%0A
                 
@@ -2489,37 +2489,40 @@
 (new Intent(
-AddEditAccoun
+ViewChangeProduc
 t.this, MyPr
@@ -3276,21 +3276,24 @@
 ent(
-AddEditAccoun
+ViewChangeProduc
 t.th
@@ -4093,18 +4093,14 @@
   %7D%0A
-    
+%0A
 */%0A%0A%0A
-%0A
 %0A%0A%7D%0A

update view change product