From 725724738e448d23c63c6d51306ac8dfb3a9cb20 Mon Sep 17 00:00:00 2001 From: Aaron Sun Date: Thu, 8 Oct 2020 18:58:50 -0700 Subject: [PATCH] Halfway through removing items from database --- .../java/com/example/listify/ListPage.java | 30 +++++++++++-------- .../listify/ui/ForgotPasswordPage.java | 11 +++++-- .../main/res/layout/activity_forgotpswd.xml | 23 ++++++++++---- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/Listify/app/src/main/java/com/example/listify/ListPage.java b/Listify/app/src/main/java/com/example/listify/ListPage.java index e25849d..354cc21 100644 --- a/Listify/app/src/main/java/com/example/listify/ListPage.java +++ b/Listify/app/src/main/java/com/example/listify/ListPage.java @@ -38,11 +38,13 @@ public class ListPage extends AppCompatActivity { Button decrQuan; Button removeItem; - ArrayList pNames = new ArrayList<>(); //String[] pNames = {"Half-gallon organic whole milk"}; - ArrayList pStores = new ArrayList<>(); //String[] pStores = {"Kroger"}; - ArrayList pPrices = new ArrayList<>(); //String[] pPrices = {"$5.00"}; - ArrayList pQuantity = new ArrayList<>(); //String[] pQuantity = {"1"}; - ArrayList pImages = new ArrayList<>(); //int[] pImages = {R.drawable.milk}; + ArrayList pNames = new ArrayList<>(); + ArrayList pStores = new ArrayList<>(); + ArrayList pPrices = new ArrayList<>(); + ArrayList pQuantity = new ArrayList<>(); + ArrayList pImages = new ArrayList<>(); + + ArrayList pListItemPair = new ArrayList<>(); Requestor requestor; @@ -93,7 +95,7 @@ public class ListPage extends AppCompatActivity { } } - pNames.add("Half-gallon organic whole milk"); + /*pNames.add("Half-gallon organic whole milk"); pStores.add("Kroger"); pPrices.add("$5.00"); pQuantity.add("1"); @@ -109,7 +111,7 @@ public class ListPage extends AppCompatActivity { pStores.add("Kroger"); pPrices.add("$7.00"); pQuantity.add("1"); - pImages.add(R.drawable.peanutbutter); + pImages.add(R.drawable.peanutbutter);*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); @@ -122,11 +124,11 @@ public class ListPage extends AppCompatActivity { class MyAdapter extends ArrayAdapter { Context context; - ArrayList pNames; //String[] pNames; - ArrayList pStores; //String[] pStores; - ArrayList pPrices; //String[] pPrices; - ArrayList pQuantity; //String[] pQuantity; - ArrayList pImages; //int[] pImages; + ArrayList pNames; + ArrayList pStores; + ArrayList pPrices; + ArrayList pQuantity; + ArrayList pImages; MyAdapter (Context c, ArrayList names, ArrayList stores, ArrayList prices, ArrayList quantity, ArrayList images) { super(c, R.layout.listproduct, R.id.productView, names); @@ -186,6 +188,9 @@ public class ListPage extends AppCompatActivity { pPrices.remove(position); pQuantity.remove(position); pImages.remove(position); + + //requestor.deleteObject("39", ListEntry.class); + listView.setAdapter(myAdapter); } }); @@ -216,6 +221,7 @@ public class ListPage extends AppCompatActivity { ProductReceiver pr = new ProductReceiver<>(); requestor.getObject(Integer.toString(product), Item.class, pr); pQuantity.add("1"); + pListItemPair.add(entry); } } } diff --git a/Listify/app/src/main/java/com/example/listify/ui/ForgotPasswordPage.java b/Listify/app/src/main/java/com/example/listify/ui/ForgotPasswordPage.java index 1a46ca8..67ec49b 100644 --- a/Listify/app/src/main/java/com/example/listify/ui/ForgotPasswordPage.java +++ b/Listify/app/src/main/java/com/example/listify/ui/ForgotPasswordPage.java @@ -15,6 +15,9 @@ import androidx.appcompat.app.AppCompatActivity; public class ForgotPasswordPage extends AppCompatActivity implements CodePage.CodeDialogListener { private Button button1; //Code page button + String email; + String newPassword; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -25,7 +28,11 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co @Override public void onClick(View v) { EditText emailText = (EditText) findViewById(R.id.editTextTextEmailAddress2); - String email = emailText.getText().toString(); + EditText newPasswordText = (EditText) findViewById(R.id.editTextTextPassword2); + + email = emailText.getText().toString(); + newPassword = newPasswordText.getText().toString(); + try { am.changePassword(email); } @@ -46,7 +53,7 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co public void sendCode(String code, boolean cancel) { if(!cancel) { try { - am.confirmPasswordReset("qwertyuiop", code); + am.confirmPasswordReset(newPassword, code); } catch (Exception e) { Log.i("Authentication", e.toString()); diff --git a/Listify/app/src/main/res/layout/activity_forgotpswd.xml b/Listify/app/src/main/res/layout/activity_forgotpswd.xml index b65d92e..413d087 100644 --- a/Listify/app/src/main/res/layout/activity_forgotpswd.xml +++ b/Listify/app/src/main/res/layout/activity_forgotpswd.xml @@ -9,29 +9,40 @@ android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="31dp" + android:layout_marginTop="27dp" android:text="Button" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress2" /> + app:layout_constraintEnd_toEndOf="@+id/editTextTextPassword2" + app:layout_constraintStart_toStartOf="@+id/editTextTextPassword2" + app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword2" /> + +