Commit 97555dfb authored by austin.blanke's avatar austin.blanke

Performance List In progress

parent e689cc5e
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
......
......@@ -8,38 +8,135 @@ import android.database.sqlite.SQLiteOpenHelper;
import androidx.annotation.Nullable;
import java.util.ArrayList;
public class DatabaseConnector extends SQLiteOpenHelper {
private static final String DB_NAME = "Registration.db";
private static final int DB_VERSION = 1;
private static final String TABLE_USERS = "Users";
private static final String COLUMN_UID = "uid";
private static final String COLUMN_USERNAME = "username";
private static final String COLUMN_PASSWORD = "password";
public DatabaseConnector(Context context, SQLiteDatabase.CursorFactory factory)
{
private static final String TABLE_PERFORMANCES = "performances";
private static final String COLUMN_PERFORMANCEID = "performanceID";
private static final String COLUMN_NAME = "name";
private static final String COLUMN_DATE = "date";
private static final String COLUMN_TIME = "time";
private static final String COLUMN_VENUE = "venue";
private static final String COLUMN_FLASH = "flash";
private static final String COLUMN_WHEELCHAIR = "wheelchair";
private static final String COLUMN_STEPS = "steps";
private static final String COLUMN_TICSEAT = "ticSeat";
private static final String COLUMN_TICSTAND = "ticStand";
private static final String COLUMN_TICSTAGE = "ticStage";
private static final String COLUMN_TICGRASS = "ticGrass";
private static final String COLUMN_TICBOATA = "ticBoatA";
private static final String COLUMN_TICBOATB = "ticBoatB";
private static final String COLUMN_TICRIVERBANK = "ticRiverBank";
private static final String COLUMN_TICINNERCIRCLE = "ticInnerCircle";
private static final String COLUMN_TICOUTTERCIRCLE = "ticOutterCircle";
public DatabaseConnector(Context context, SQLiteDatabase.CursorFactory factory) {
super(context, DB_NAME, factory, DB_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_table = "CREATE TABLE "+TABLE_USERS+"("+
COLUMN_UID+" INTEGER PRIMARY KEY, " +
String CREATE_table1 = "CREATE TABLE " + TABLE_USERS + "(" +
COLUMN_UID + " INTEGER PRIMARY KEY, " +
COLUMN_USERNAME + " TEXT, " +
COLUMN_PASSWORD + " TEXT)";
db.execSQL(CREATE_table);
db.execSQL(CREATE_table1);
String CREATE_table2 = "CREATE TABLE " + TABLE_PERFORMANCES + "(" +
COLUMN_PERFORMANCEID + " INTEGER PRIMARY KEY, " +
COLUMN_NAME + " TEXT, " +
COLUMN_DATE + " TEXT, " +
COLUMN_TIME + " TEXT, " +
COLUMN_VENUE + " TEXT, " +
COLUMN_FLASH + " TEXT, " +
COLUMN_WHEELCHAIR + " TEXT, " +
COLUMN_STEPS + " TEXT, " +
COLUMN_TICSEAT + " TEXT, " +
COLUMN_TICSTAND + " TEXT, " +
COLUMN_TICSTAGE + " TEXT, " +
COLUMN_TICGRASS + " TEXT, " +
COLUMN_TICBOATA + " TEXT, " +
COLUMN_TICBOATB + " TEXT, " +
COLUMN_TICRIVERBANK + " TEXT, " +
COLUMN_TICINNERCIRCLE + " TEXT, " +
COLUMN_TICOUTTERCIRCLE + " TEXT)";
db.execSQL(CREATE_table2);
ContentValues play1 = new ContentValues();
play1.put(COLUMN_NAME, "The Merchant of Venice by William Shakespeare");
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_WHEELCHAIR, "true");
play1.put(COLUMN_TICSEAT, "17,8");
db.insert(TABLE_PERFORMANCES, null, play1);
ContentValues play2 = new ContentValues();
play2.put(COLUMN_NAME, "Hamlet by William Shakespeare");
play2.put(COLUMN_DATE, "Friday 19 May 2023");
play2.put(COLUMN_TIME, "18:00");
play2.put(COLUMN_VENUE, "Clifford's Tower, York");
play2.put(COLUMN_FLASH, "true");
play2.put(COLUMN_STEPS, "true");
play2.put(COLUMN_TICSEAT, "8,8");
db.insert(TABLE_PERFORMANCES, null, play2);
ContentValues play3 = new ContentValues();
play3.put(COLUMN_NAME, "A Midsummer Night's Dream by William Shakespeare");
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_TICSTAGE, "11,4");
play3.put(COLUMN_TICGRASS, "29,4");
db.insert(TABLE_PERFORMANCES, null, play3);
ContentValues play4 = new ContentValues();
play4.put(COLUMN_NAME, "Oedipus the King by Sophocles");
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_WHEELCHAIR, "true");
play4.put(COLUMN_TICSEAT, "5,9");
play4.put(COLUMN_TICSTAND, "12,7");
db.insert(TABLE_PERFORMANCES, null, play4);
ContentValues play5 = new ContentValues();
play5.put(COLUMN_NAME, "The Tempest by William Shakespeare");
play5.put(COLUMN_DATE, "Saturday 19 August");
play5.put(COLUMN_TIME, "14:00");
play5.put(COLUMN_VENUE, "Millennium Bridge, York");
play5.put(COLUMN_WHEELCHAIR, "true");
play5.put(COLUMN_TICBOATA, "6,9");
play5.put(COLUMN_TICRIVERBANK, "10,7");
db.insert(TABLE_PERFORMANCES, null, play5);
ContentValues play6 = new ContentValues();
play6.put(COLUMN_NAME, "Antigone by Sophocles");
play6.put(COLUMN_DATE, "Thursday 20 September");
play6.put(COLUMN_TIME, "21:00");
play6.put(COLUMN_VENUE, "Crypt, York Minster, York");
play6.put(COLUMN_STEPS, "true");
play6.put(COLUMN_TICINNERCIRCLE, "5,16");
play6.put(COLUMN_TICOUTTERCIRCLE, "8,13");
play6.put(COLUMN_TICSTAND, "10,10");
db.insert(TABLE_PERFORMANCES, null, play6);
}
public void addNewUser(String username, String password)
{
public void addNewUser(String username, String password) {
ContentValues values = new ContentValues();
values.put(COLUMN_USERNAME, username);
values.put(COLUMN_PASSWORD, password);
......@@ -54,16 +151,15 @@ public class DatabaseConnector extends SQLiteOpenHelper {
}
public boolean usernameRepeat(String username){
public boolean usernameRepeat(String username) {
boolean result = false;
String query = "SELECT * FROM " + TABLE_USERS + " WHERE " + COLUMN_USERNAME + " = \"" + username +"\"";
String query = "SELECT * FROM " + TABLE_USERS + " WHERE " + COLUMN_USERNAME + " = \"" + username + "\"";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
if(cursor.getCount() == 0){
if (cursor.getCount() == 0) {
result = false;
}
else result = true;
} else result = true;
cursor.close();
......@@ -73,13 +169,13 @@ public class DatabaseConnector extends SQLiteOpenHelper {
}
public boolean login(String username, String password) {
String query = "SELECT * FROM " + TABLE_USERS + " WHERE " + COLUMN_USERNAME + " = \"" + username +"\"";
String query = "SELECT * FROM " + TABLE_USERS + " WHERE " + COLUMN_USERNAME + " = \"" + username + "\"";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
boolean result = false;
if (cursor.moveToFirst()){
if (cursor.moveToFirst()) {
if (cursor.getString(2).equals(password))
result = true;
else
......@@ -91,4 +187,32 @@ public class DatabaseConnector extends SQLiteOpenHelper {
return result;
}
}
public ArrayList performances() {
ArrayList<ArrayList<String>> performancesList = new ArrayList<>();
String query = "SELECT * FROM " + TABLE_PERFORMANCES;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
String info;
cursor.moveToFirst();
for (int i = 0; i < cursor.getCount(); i++) {
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.close();
db.close();
return performancesList;
}
}
\ No newline at end of file
package com.example.bookingapp_austinblanke;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.TextView;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Bundle loginBundle = getIntent().getExtras();
String currentUser = loginBundle.getString("currentUser");
TextView username = (TextView) findViewById(R.id.Username);
username.setText(currentUser);
performanceList = new ArrayList<>();
RecyclerView recyclerObj = findViewById(R.id.performanceRecycler);
recyclerObj.setLayoutManager(new LinearLayoutManager(this));
adapter = new performanceRecAdapter(this, performanceList);
recyclerObj.setAdapter(adapter);
}
}
\ No newline at end of file
package com.example.bookingapp_austinblanke;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
public class MyAdapter extends RecyclerView.Adapter<MyViewHolder> {
private Context context;
private ArrayList name_id;
public MyAdapter(Context context, ArrayList name_id) {
this.context = context;
this.name_id = name_id;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(context).inflate(R.layout.performance,parent,false);
return new MyViewHolder(v);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
}
@Override
public int getItemCount() {
return 0;
}
}
package com.example.bookingapp_austinblanke;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
public class MyViewHolder extends RecyclerView.ViewHolder{
TextView name;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cardElevation="12dp"
android:cardCornerRadius="16dp"
android:layout_margin="16dp"
android:backgroundTint="#efefef">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
androidtext="Performance"
android
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
\ 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