Commit f2850306 authored by a-j.towse's avatar a-j.towse

half working filter

parent bac7ba9a
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -260,6 +260,7 @@ public class DBConnector extends SQLiteOpenHelper {
}
//Upgrade DB (to satisfy extends f SQLiteOpenHelper)
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
......
......@@ -3,11 +3,15 @@ package com.example.no1theatrecompany;
public class IdleData {
String name;
String date;
String ticketsLeft;
IdleData(String name)
IdleData(String name,String date,String ticketsLeft)
{
this.name = name;
this.date = date;
this.ticketsLeft = ticketsLeft;
}
}
......@@ -8,15 +8,22 @@ import androidx.recyclerview.widget.RecyclerView;
public class IdleViewHolder extends RecyclerView.ViewHolder
{
TextView nameText;
TextView dateText;
TextView ticketsLeftText;
IdleViewHolder(View v) {
super(v);
nameText = itemView.findViewById(R.id.performanceName);
dateText =itemView.findViewById(R.id.performanceDate);
ticketsLeftText=itemView.findViewById(R.id.ticketsLeft);
}
void setData(IdleData data)
{
nameText.setText(data.name);
dateText.setText(data.date);
ticketsLeftText.setText(data.ticketsLeft);
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
import java.util.ArrayList;
......@@ -17,6 +18,7 @@ public class MainActivity extends AppCompatActivity {
performanceRecAdapter adapter;
ArrayList<IdleData> performanceList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -40,17 +42,97 @@ public class MainActivity extends AppCompatActivity {
DBConnector connector = new DBConnector(this, null);
ArrayList performanceInfoList = connector.getPerformanceInfo();
//Display items of performanceInfoList
for (int i = 0;i<performanceInfoList.size();i++) {
ArrayList tempList = (ArrayList) performanceInfoList.get(i);
performanceList.add(performanceList.size(), new IdleData(tempList.get(0).toString()));
this.adapter.notifyItemInserted(this.adapter.getItemCount());
String ticketNum = null;
int ticketCount = 0;
//count the number of tickets left
for (int x=7;x<tempList.size();x++) {
if (tempList.get(x) != null) {
String unSplitItem = tempList.get(x).toString();
String Num = unSplitItem.substring(0,unSplitItem.indexOf(","));
ticketCount+=Integer.parseInt(Num);
}
}
performanceList.add(performanceList.size(), new IdleData(tempList.get(0).toString(),
tempList.get(1).toString(),
Integer.toString(ticketCount)));
this.adapter.notifyItemInserted(this.adapter.getItemCount());
}
}
public void logOutBtn(View view) {
startActivity(new Intent(MainActivity.this, LoginActivity.class));
}
public void applyFilterBtn(View view) {
filterPerformances();
}
public void filterPerformances () {
boolean flashIsChecked = ((CheckBox) findViewById(R.id.flashCheckBox)).isChecked();
boolean stepsIsChecked = ((CheckBox) findViewById(R.id.stepsCheckBox)).isChecked();
boolean wheelIsChecked = ((CheckBox) findViewById(R.id.wheelAccessCheckBox)).isChecked();
//connect to DBConnector
DBConnector connector = new DBConnector(this, null);
ArrayList performanceInfoList = connector.getPerformanceInfo();
for (int i = 0; i < performanceInfoList.size(); i++) {
ArrayList tempList = (ArrayList) performanceInfoList.get(i);
if (flashIsChecked == true) {
if (tempList.get(5) == null) {
performanceInfoList.remove(i);
}
}
else if (stepsIsChecked == true) {
if (tempList.get(6) == null) {
performanceInfoList.remove(i);
}
}
else if (wheelIsChecked == true) {
if (tempList.get(7) == null) {
performanceInfoList.remove(i);
}
}
}
performanceList = new ArrayList<>();
RecyclerView recyclerObj = findViewById(R.id.performanceRecycler);
recyclerObj.setLayoutManager(new LinearLayoutManager(this));
adapter = new performanceRecAdapter(this, performanceList);
recyclerObj.setAdapter(adapter);
//Display items of performanceInfoList
for (int i = 0;i<performanceInfoList.size();i++) {
ArrayList tempList = (ArrayList) performanceInfoList.get(i);
String ticketNum = null;
int ticketCount = 0;
//count the number of tickets left
for (int x=7;x<tempList.size();x++) {
if (tempList.get(x) != null) {
String unSplitItem = tempList.get(x).toString();
String Num = unSplitItem.substring(0,unSplitItem.indexOf(","));
ticketCount+=Integer.parseInt(Num);
}
}
performanceList.add(performanceList.size(), new IdleData(tempList.get(0).toString(),
tempList.get(1).toString(),
Integer.toString(ticketCount)));
this.adapter.notifyItemInserted(this.adapter.getItemCount());
}
}
}
\ No newline at end of file
......@@ -4,8 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F0EDE6
"
android:background="#F0EDE6"
tools:context=".MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout
......@@ -16,6 +15,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/usernameTextView"
android:layout_width="108dp"
android:layout_height="23dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.947"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/logOutBtn"
android:layout_width="wrap_content"
......@@ -27,44 +36,71 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/usernameTextView"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="258dp"
android:layout_width="411dp"
android:layout_height="120dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/no_1_theatreco" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="409dp"
android:layout_height="450dp"
android:id="@+id/constraintLayout2"
android:layout_width="0dp"
android:layout_height="109dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/constraintLayout">
<Button
android:id="@+id/filterBtn"
android:layout_width="85dp"
android:layout_height="43dp"
android:layout_marginEnd="8dp"
android:text="Filter"
android:layout_width="138dp"
android:layout_height="48dp"
android:layout_marginEnd="16dp"
android:onClick="applyFilterBtn"
android:text="Apply Filter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<CheckBox
android:id="@+id/flashCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="No Flashing Lights"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="@+id/wheelAccessCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:text="Wheelchair Accessible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/flashCheckBox" />
<CheckBox
android:id="@+id/stepsCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="Less Than 20 Steps"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="409dp"
android:layout_height="450dp"
android:layout_marginTop="30dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/constraintLayout2">
<TextView
android:id="@+id/textViewPerformances"
......@@ -84,22 +120,27 @@
android:layout_width="407dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/filterBtn">
app:layout_constraintTop_toBottomOf="@+id/textViewPerformances">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/performanceRecycler"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/beige"
android:fadeScrollbars="false"
android:scrollIndicators="bottom"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbarSize="5dp"
android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -14,12 +15,53 @@
android:id="@+id/performanceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="TextView"
android:textAlignment="center"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="@+id/performanceDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="TextView"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/performanceName" />
<TextView
android:id="@+id/ticketsLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="10dp"
android:text="TextView"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/performanceName" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="10dp"
android:text="Tickets Available:"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/ticketsLeft"
app:layout_constraintTop_toBottomOf="@+id/performanceName" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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