Commit a910ea37 authored by austin.blanke's avatar austin.blanke

Working Recycler Linked to Database and Filter in Progress

parent e5419a99
...@@ -74,6 +74,7 @@ public class DatabaseConnector extends SQLiteOpenHelper { ...@@ -74,6 +74,7 @@ public class DatabaseConnector extends SQLiteOpenHelper {
db.execSQL(CREATE_table2); db.execSQL(CREATE_table2);
ContentValues play1 = new ContentValues(); ContentValues play1 = new ContentValues();
play1.put(COLUMN_PERFORMANCEID, 1);
play1.put(COLUMN_NAME, "The Merchant of Venice by William Shakespeare"); play1.put(COLUMN_NAME, "The Merchant of Venice by William Shakespeare");
play1.put(COLUMN_DATE, "Sunday April 23 2023"); play1.put(COLUMN_DATE, "Sunday April 23 2023");
play1.put(COLUMN_TIME, "20:00"); play1.put(COLUMN_TIME, "20:00");
...@@ -83,6 +84,7 @@ public class DatabaseConnector extends SQLiteOpenHelper { ...@@ -83,6 +84,7 @@ public class DatabaseConnector extends SQLiteOpenHelper {
db.insert(TABLE_PERFORMANCES, null, play1); db.insert(TABLE_PERFORMANCES, null, play1);
ContentValues play2 = new ContentValues(); ContentValues play2 = new ContentValues();
play2.put(COLUMN_PERFORMANCEID, 2);
play2.put(COLUMN_NAME, "Hamlet by William Shakespeare"); play2.put(COLUMN_NAME, "Hamlet by William Shakespeare");
play2.put(COLUMN_DATE, "Friday 19 May 2023"); play2.put(COLUMN_DATE, "Friday 19 May 2023");
play2.put(COLUMN_TIME, "18:00"); play2.put(COLUMN_TIME, "18:00");
...@@ -93,6 +95,7 @@ public class DatabaseConnector extends SQLiteOpenHelper { ...@@ -93,6 +95,7 @@ public class DatabaseConnector extends SQLiteOpenHelper {
db.insert(TABLE_PERFORMANCES, null, play2); db.insert(TABLE_PERFORMANCES, null, play2);
ContentValues play3 = new ContentValues(); ContentValues play3 = new ContentValues();
play3.put(COLUMN_PERFORMANCEID, 3);
play3.put(COLUMN_NAME, "A Midsummer Night's Dream by William Shakespeare"); play3.put(COLUMN_NAME, "A Midsummer Night's Dream by William Shakespeare");
play3.put(COLUMN_DATE, "Saturday 3 June 2023"); play3.put(COLUMN_DATE, "Saturday 3 June 2023");
play3.put(COLUMN_TIME, "19:00"); play3.put(COLUMN_TIME, "19:00");
...@@ -104,6 +107,7 @@ public class DatabaseConnector extends SQLiteOpenHelper { ...@@ -104,6 +107,7 @@ public class DatabaseConnector extends SQLiteOpenHelper {
db.insert(TABLE_PERFORMANCES, null, play3); db.insert(TABLE_PERFORMANCES, null, play3);
ContentValues play4 = new ContentValues(); ContentValues play4 = new ContentValues();
play4.put(COLUMN_PERFORMANCEID, 4);
play4.put(COLUMN_NAME, "Oedipus the King by Sophocles"); play4.put(COLUMN_NAME, "Oedipus the King by Sophocles");
play4.put(COLUMN_DATE, "Friday 28 July"); play4.put(COLUMN_DATE, "Friday 28 July");
play4.put(COLUMN_TIME, "20:00"); play4.put(COLUMN_TIME, "20:00");
...@@ -114,6 +118,7 @@ public class DatabaseConnector extends SQLiteOpenHelper { ...@@ -114,6 +118,7 @@ public class DatabaseConnector extends SQLiteOpenHelper {
db.insert(TABLE_PERFORMANCES, null, play4); db.insert(TABLE_PERFORMANCES, null, play4);
ContentValues play5 = new ContentValues(); ContentValues play5 = new ContentValues();
play5.put(COLUMN_PERFORMANCEID, 5);
play5.put(COLUMN_NAME, "The Tempest by William Shakespeare"); play5.put(COLUMN_NAME, "The Tempest by William Shakespeare");
play5.put(COLUMN_DATE, "Saturday 19 August"); play5.put(COLUMN_DATE, "Saturday 19 August");
play5.put(COLUMN_TIME, "14:00"); play5.put(COLUMN_TIME, "14:00");
...@@ -124,6 +129,7 @@ public class DatabaseConnector extends SQLiteOpenHelper { ...@@ -124,6 +129,7 @@ public class DatabaseConnector extends SQLiteOpenHelper {
db.insert(TABLE_PERFORMANCES, null, play5); db.insert(TABLE_PERFORMANCES, null, play5);
ContentValues play6 = new ContentValues(); ContentValues play6 = new ContentValues();
play6.put(COLUMN_PERFORMANCEID, 6);
play6.put(COLUMN_NAME, "Antigone by Sophocles"); play6.put(COLUMN_NAME, "Antigone by Sophocles");
play6.put(COLUMN_DATE, "Thursday 20 September"); play6.put(COLUMN_DATE, "Thursday 20 September");
play6.put(COLUMN_TIME, "21:00"); play6.put(COLUMN_TIME, "21:00");
...@@ -188,31 +194,25 @@ public class DatabaseConnector extends SQLiteOpenHelper { ...@@ -188,31 +194,25 @@ public class DatabaseConnector extends SQLiteOpenHelper {
return result; return result;
} }
public ArrayList performances() { public ArrayList performanceTitles(String filter) {
ArrayList<ArrayList<String>> performancesList = new ArrayList<>();
ArrayList<String> performances = new ArrayList<>();
String query = "SELECT * FROM " + TABLE_PERFORMANCES; String query = "SELECT * FROM " + TABLE_PERFORMANCES;
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null); Cursor cursor = db.rawQuery(query, null);
String info; String title;
cursor.moveToFirst(); cursor.moveToFirst();
for(int i=0;i< cursor.getCount();i++){
for (int i = 0; i < cursor.getCount(); i++) { if (cursor.getString(5).equals(filter) || cursor.getString(6).equals(filter) || cursor.getString(7).equals(filter))
performances.add(cursor.getString(1));
ArrayList<String> tempList = new ArrayList<>();
for (int column = 1; column < cursor.getColumnCount(); column++) {
info = cursor.getString(column);
tempList.add(info);
}
performancesList.add(tempList);
cursor.moveToNext(); cursor.moveToNext();
} }
//Close DB
cursor.close(); cursor.close();
db.close(); db.close();
return performancesList; return performances;
} }
} }
\ No newline at end of file
...@@ -8,8 +8,11 @@ import androidx.recyclerview.widget.RecyclerView; ...@@ -8,8 +8,11 @@ import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View; import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -18,23 +21,48 @@ import java.util.ArrayList; ...@@ -18,23 +21,48 @@ import java.util.ArrayList;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
adapter adapterObj; adapter adapterObj;
ArrayList<String> dataList; ArrayList<String> performanceList;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
dataList = new ArrayList<>(); CheckBox flash=(CheckBox)findViewById(R.id.Flash);
dataList.add("Test1"); CheckBox wheelChair=(CheckBox)findViewById(R.id.Wheelchair);
dataList.add("Test2"); CheckBox stairs=(CheckBox)findViewById(R.id.Stairs);
dataList.add("Test3");
dataList.add("Test4"); String filter = null;
dataList.add("Test5");
DatabaseConnector connector = new DatabaseConnector(this, null);
performanceList = new ArrayList<>();
performanceList = connector.performanceTitles(filter);
RecyclerView recyclerObj = findViewById(R.id.performances); RecyclerView recyclerObj = findViewById(R.id.performances);
recyclerObj.setLayoutManager(new LinearLayoutManager(this)); recyclerObj.setLayoutManager(new LinearLayoutManager(this));
adapterObj = new adapter(this, dataList); adapterObj = new adapter(this, performanceList);
recyclerObj.setAdapter(adapterObj); recyclerObj.setAdapter(adapterObj);
}
public void filter(View v)
{
Boolean filter1 = false;
Boolean filter2 = false;
Boolean filter3 = false;
if(flash.isChecked()) {filter1 = true;}
else {filter1 = false;}
if(wheelchair.isChecked()) {filter2 = true;}
else {filter2 = false;}
if(stairs.isChecked()) {filter3 = true;}
else {filter3 = false;}
Toast.makeText(this, msg + "are selected",
Toast.LENGTH_LONG).show();
} }
} }
\ No newline at end of file
...@@ -7,13 +7,65 @@ ...@@ -7,13 +7,65 @@
android:background="#F2F1E8" android:background="#F2F1E8"
tools:context=".MainActivity"> tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/performances" android:id="@+id/performances"
android:layout_width="match_parent" android:layout_width="410dp"
android:layout_height="match_parent" android:layout_height="409dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.993"
tools:ignore="MissingConstraints" />
<Button
android:id="@+id/filter"
android:layout_width="240dp"
android:layout_height="54dp"
android:text="Update Filter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.206" />
<CheckBox
android:id="@+id/Wheelchair"
android:layout_width="146dp"
android:layout_height="73dp"
android:text="Wheelchair Access"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.943"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.311" />
<CheckBox
android:id="@+id/Flash"
android:layout_width="90dp"
android:layout_height="71dp"
android:text="No Flash"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.024"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.309" />
<CheckBox
android:id="@+id/Stairs"
android:layout_width="132dp"
android:layout_height="75dp"
android:text="Below 20 Stairs"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.376"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.31" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
android:background="#CCCCCC" android:background="#CCCCCC"
/> />
<Button
android:id="@+id/moreInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="moreInfo" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment