From dd43d324b7ca3e01b140f5c6c65768399c9d83b6 Mon Sep 17 00:00:00 2001 From: savannah-nelson Date: Fri, 5 Nov 2021 19:41:49 -0400 Subject: [PATCH 1/6] test commit --- .idea/misc.xml | 6 +++++- .../main/java/com/example/cmsc355cookbookapp/Pantry.java | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index edec60b..37ee874 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,6 +3,10 @@ - + diff --git a/app/src/main/java/com/example/cmsc355cookbookapp/Pantry.java b/app/src/main/java/com/example/cmsc355cookbookapp/Pantry.java index f437280..2a05162 100644 --- a/app/src/main/java/com/example/cmsc355cookbookapp/Pantry.java +++ b/app/src/main/java/com/example/cmsc355cookbookapp/Pantry.java @@ -14,6 +14,8 @@ import java.util.ArrayList; + +//savannah test commit public class Pantry extends AppCompatActivity { ListView listView; ArrayList items; From 25b89e812c82342adf1ca50baa80c71818fc2209 Mon Sep 17 00:00:00 2001 From: savannah-nelson Date: Sun, 21 Nov 2021 21:39:31 -0500 Subject: [PATCH 2/6] started to work on implementing db --- .../example/cmsc355cookbookapp/Pantry.java | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/example/cmsc355cookbookapp/Pantry.java b/app/src/main/java/com/example/cmsc355cookbookapp/Pantry.java index 2a05162..918f366 100644 --- a/app/src/main/java/com/example/cmsc355cookbookapp/Pantry.java +++ b/app/src/main/java/com/example/cmsc355cookbookapp/Pantry.java @@ -1,5 +1,6 @@ package com.example.cmsc355cookbookapp; +import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.widget.Adapter; @@ -14,9 +15,31 @@ import java.util.ArrayList; +public final class PantryDB { + // To prevent someone from accidentally instantiating the contract class, + // make the constructor private. + private PantryDB() {} + + /* Inner class that defines the table contents */ + public static class Ingredient implements BaseColumns { + public static final String TABLE_NAME = "ingr"; + public static final String COLUMN_NAME = "name"; + } + + + private static final String SQL_CREATE_ENTRIES = + "CREATE TABLE " + Ingredient.TABLE_NAME + " (" + + Ingredient._ID + " INTEGER PRIMARY KEY," + + Ingredient.COLUMN_NAME + " TEXT," + + Ingredient._COUNT + " TEXT"; + + private static final String SQL_DELETE_ENTRIES = + "DROP TABLE IF EXISTS " + Ingredient.TABLE_NAME; +} -//savannah test commit public class Pantry extends AppCompatActivity { + public static final String DATABASE_NAME = "MyPantry.db"; + ListView listView; ArrayList items; ArrayAdapter adapter; @@ -24,20 +47,18 @@ public class Pantry extends AppCompatActivity { EditText input; ImageView enter; - @Override - protected void onCreate(Bundle savedInstanceState){ + //@Override + protected void onCreate(Bundle savedInstanceState, SQLiteDatabase db){ super.onCreate(savedInstanceState); setContentView(R.layout.pantry_layout); + db.execSQL(SQL_CREATE_ENTRIES); listView = findViewById(R.id.listview); input = findViewById(R.id.input); enter = findViewById(R.id.add); - items = new ArrayList<>(); - items.add("Apple"); - items.add("Banana"); - items.add("Green Onions"); - items.add("Big Apples"); + //create pantry db + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override From c5b488378cb769aa2c9622dc8a06ddcd77a22909 Mon Sep 17 00:00:00 2001 From: savannah-nelson Date: Sat, 11 Dec 2021 17:20:40 -0500 Subject: [PATCH 3/6] Update activity_main.xml --- app/src/main/res/layout/activity_main.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 1e4f8b6..726e48f 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -27,12 +27,12 @@ android:layout_marginTop="84dp" android:layout_marginEnd="139dp" android:layout_marginBottom="21dp" - android:text="Fill Up Your Pantry!" + android:text="Pantry" app:layout_constraintBottom_toTopOf="@+id/recipe_btn" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.525" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/textView2" - /> + app:layout_constraintTop_toBottomOf="@+id/textView2" />