Commit 41ac9e31 authored by a-j.towse's avatar a-j.towse

working info display page

parent 87ff3eb7
package com.example.no1theatrecompany; package com.example.no1theatrecompany;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class performanceInfoPage extends AppCompatActivity { public class performanceInfoPage extends AppCompatActivity {
...@@ -30,18 +33,59 @@ public class performanceInfoPage extends AppCompatActivity { ...@@ -30,18 +33,59 @@ public class performanceInfoPage extends AppCompatActivity {
onBackPressed(); onBackPressed();
} }
@SuppressLint("SetTextI18n")
void setInfo(String performance) { void setInfo(String performance) {
System.out.println(performance);
TextView nameTextView = (TextView) findViewById(R.id.performanceTitle); TextView nameTextView = (TextView) findViewById(R.id.performanceTitle);
TextView dateTimeTextView = (TextView) findViewById(R.id.dateTimetextView); TextView dateTimeTextView = (TextView) findViewById(R.id.dateTimetextView);
TextView venueTextView = (TextView) findViewById(R.id.venuetextView);
switch(performance) { //Connect to DB
DBConnector connector = new DBConnector(this, null);
ArrayList performanceInfoList = connector.getPerformanceInfo();
ArrayList currentPerformance = null;
for (int i = 0; i < performanceInfoList.size(); i++) {
ArrayList tempList = (ArrayList) performanceInfoList.get(i);
if (tempList.get(0).equals(performance)) {
currentPerformance = (ArrayList) tempList;
break;
}
}
nameTextView.setText(currentPerformance.get(0).toString());
dateTimeTextView.setText(currentPerformance.get(1).toString());
venueTextView.setText((currentPerformance.get(3).toString()+ ": "+
currentPerformance.get(2).toString()));
int ticketTypeCount = 0;
//count the number of tickets types left
for (int x=7;x<currentPerformance.size();x++) {
if (currentPerformance.get(x) != null) {
ticketTypeCount+=1;
}
}
System.out.println(currentPerformance);
/*switch (performance) {
case "The Tempest": case "The Tempest":
nameTextView.setText("The Tempest"); nameTextView.setText("The Tempest");
case "A Midsummer Night's Dream by William Shakespeare": case "A Midsummer Night's Dream by William Shakespeare":
nameTextView.setText("A Midsummer Night's Dream by William Shakespeare"); nameTextView.setText(currentPerformance.get(0).toString());
dateTimeTextView.setText("Saturday 3 June 2023, 19:00"); dateTimeTextView.setText("Saturday 3 June 2023, 19:00");
} venueTextView.setText("Dean's Park, York");
for (int i = 0; i < performanceInfoList.size(); i++) {
final LinearLayout linearLayout = (LinearLayout) findViewById(R.id.bookTicketsLayout);
final TextView text = new TextView(this);
text.setText("Hello World");
linearLayout.addView(text);
}
}*/
} }
} }
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="@color/beigeWhite">
<Button <Button
android:id="@+id/backBtn" android:id="@+id/backBtn"
...@@ -11,17 +12,22 @@ ...@@ -11,17 +12,22 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:text="Back"
android:onClick="backBtn" android:onClick="backBtn"
android:text="Back"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<LinearLayout <LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:backgroundTint="@color/beige"
android:baselineAligned="false"
android:dividerPadding="10dp"
android:foregroundTintMode="add"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
...@@ -31,16 +37,47 @@ ...@@ -31,16 +37,47 @@
android:id="@+id/performanceTitle" android:id="@+id/performanceTitle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:fontFamily="sans-serif" android:fontFamily="sans-serif"
android:text="TextView" android:text="TextView"
android:textAlignment="center" android:textAlignment="center"
android:textSize="20sp" /> android:textSize="28sp" />
<TextView <TextView
android:id="@+id/dateTimetextView" android:id="@+id/dateTimetextView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="TextView" /> android:layout_marginBottom="10dp"
android:text="TextView"
android:textSize="20sp" />
<TextView
android:id="@+id/venuetextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="TextView"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/bookTicketsLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2">
<TextView
android:id="@+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Book Tickets:" />
</LinearLayout> </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </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