Commit 824f7047 authored by austin.blanke's avatar austin.blanke

Filter Work in Progress

parent a910ea37
......@@ -79,7 +79,9 @@ public class DatabaseConnector extends SQLiteOpenHelper {
play1.put(COLUMN_DATE, "Sunday April 23 2023");
play1.put(COLUMN_TIME, "20:00");
play1.put(COLUMN_VENUE, "Merchant Adventurer's Hall, York");
play1.put(COLUMN_FLASH, "false");
play1.put(COLUMN_WHEELCHAIR, "true");
play1.put(COLUMN_STEPS, "false");
play1.put(COLUMN_TICSEAT, "17,8");
db.insert(TABLE_PERFORMANCES, null, play1);
......@@ -90,6 +92,7 @@ public class DatabaseConnector extends SQLiteOpenHelper {
play2.put(COLUMN_TIME, "18:00");
play2.put(COLUMN_VENUE, "Clifford's Tower, York");
play2.put(COLUMN_FLASH, "true");
play2.put(COLUMN_WHEELCHAIR, "false");
play2.put(COLUMN_STEPS, "true");
play2.put(COLUMN_TICSEAT, "8,8");
db.insert(TABLE_PERFORMANCES, null, play2);
......@@ -100,8 +103,9 @@ public class DatabaseConnector extends SQLiteOpenHelper {
play3.put(COLUMN_DATE, "Saturday 3 June 2023");
play3.put(COLUMN_TIME, "19:00");
play3.put(COLUMN_VENUE, "Dean's Park, York");
play3.put(COLUMN_WHEELCHAIR, "true");
play3.put(COLUMN_FLASH, "true");
play3.put(COLUMN_WHEELCHAIR, "true");
play3.put(COLUMN_STEPS, "false");
play3.put(COLUMN_TICSTAGE, "11,4");
play3.put(COLUMN_TICGRASS, "29,4");
db.insert(TABLE_PERFORMANCES, null, play3);
......@@ -112,7 +116,9 @@ public class DatabaseConnector extends SQLiteOpenHelper {
play4.put(COLUMN_DATE, "Friday 28 July");
play4.put(COLUMN_TIME, "20:00");
play4.put(COLUMN_VENUE, "St Mary's Abbey, Museum Gardens, York");
play4.put(COLUMN_FLASH, "false");
play4.put(COLUMN_WHEELCHAIR, "true");
play4.put(COLUMN_STEPS, "false");
play4.put(COLUMN_TICSEAT, "5,9");
play4.put(COLUMN_TICSTAND, "12,7");
db.insert(TABLE_PERFORMANCES, null, play4);
......@@ -123,7 +129,9 @@ public class DatabaseConnector extends SQLiteOpenHelper {
play5.put(COLUMN_DATE, "Saturday 19 August");
play5.put(COLUMN_TIME, "14:00");
play5.put(COLUMN_VENUE, "Millennium Bridge, York");
play5.put(COLUMN_FLASH, "false");
play5.put(COLUMN_WHEELCHAIR, "true");
play5.put(COLUMN_STEPS, "false");
play5.put(COLUMN_TICBOATA, "6,9");
play5.put(COLUMN_TICRIVERBANK, "10,7");
db.insert(TABLE_PERFORMANCES, null, play5);
......@@ -134,6 +142,8 @@ public class DatabaseConnector extends SQLiteOpenHelper {
play6.put(COLUMN_DATE, "Thursday 20 September");
play6.put(COLUMN_TIME, "21:00");
play6.put(COLUMN_VENUE, "Crypt, York Minster, York");
play6.put(COLUMN_FLASH, "false");
play6.put(COLUMN_WHEELCHAIR, "false");
play6.put(COLUMN_STEPS, "true");
play6.put(COLUMN_TICINNERCIRCLE, "5,16");
play6.put(COLUMN_TICOUTTERCIRCLE, "8,13");
......@@ -194,17 +204,18 @@ public class DatabaseConnector extends SQLiteOpenHelper {
return result;
}
public ArrayList performanceTitles(String filter) {
public ArrayList performanceTitles(boolean filter1, boolean filter2, boolean filter3) {
ArrayList<String> performances = new ArrayList<>();
String query = "SELECT * FROM " + TABLE_PERFORMANCES;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
String title;
cursor.moveToFirst();
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));
if (filter1 && filter2 && filter3)
if(cursor.getString(5).equals("false") && cursor.getString(5).equals("true") && cursor.getString(5).equals("false")){
performances.add(cursor.getString(1));
else{performances.add(cursor.getString(1));} //No filter present
cursor.moveToNext();
}
......
......@@ -6,6 +6,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.app.assist.AssistStructure;
import android.content.Intent;
import android.os.Bundle;
import android.provider.ContactsContract;
......@@ -19,7 +20,7 @@ import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
CheckBox flash, wheelChair, stairs;
adapter adapterObj;
ArrayList<String> performanceList;
......@@ -28,16 +29,16 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CheckBox flash=(CheckBox)findViewById(R.id.Flash);
CheckBox wheelChair=(CheckBox)findViewById(R.id.Wheelchair);
CheckBox stairs=(CheckBox)findViewById(R.id.Stairs);
flash = (CheckBox)findViewById(R.id.Flash);
wheelChair = (CheckBox)findViewById(R.id.Wheelchair);
stairs = (CheckBox)findViewById(R.id.Stairs);
String filter = null;
DatabaseConnector connector = new DatabaseConnector(this, null);
performanceList = new ArrayList<>();
performanceList = connector.performanceTitles(filter);
performanceList = connector.performanceTitles(false, false, false);
RecyclerView recyclerObj = findViewById(R.id.performances);
......@@ -49,20 +50,26 @@ public class MainActivity extends AppCompatActivity {
}
public void filter(View v)
public void filter(View view){ filter();}
public void filter()
{
Boolean filter1 = false;
Boolean filter2 = false;
Boolean filter3 = false;
Boolean filter1 ;
Boolean filter2 ;
Boolean filter3 ;
if(flash.isChecked()) {filter1 = true;}
else {filter1 = false;}
if(wheelchair.isChecked()) {filter2 = true;}
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();
DatabaseConnector connector = new DatabaseConnector(this, null);
performanceList = connector.performanceTitles(filter1, filter2, filter3);
RecyclerView recyclerObj = findViewById(R.id.performances);
recyclerObj.setLayoutManager(new LinearLayoutManager(this));
adapterObj = new adapter(this, performanceList);
recyclerObj.setAdapter(adapterObj);
}
}
\ No newline at end of file
......@@ -24,6 +24,7 @@
android:layout_width="240dp"
android:layout_height="54dp"
android:text="Update Filter"
android:onClick="filter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
......
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