Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
THEATERT MOBILE APP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bryan.quispe
THEATERT MOBILE APP
Commits
c6de924c
Commit
c6de924c
authored
Jun 05, 2023
by
bryan.quispe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
079cac85
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
208 additions
and
101 deletions
+208
-101
AndroidManifest.xml
MyApplication/app/src/main/AndroidManifest.xml
+1
-1
Database.java
...app/src/main/java/com/example/myapplication/Database.java
+136
-93
HomeActivity.java
...src/main/java/com/example/myapplication/HomeActivity.java
+71
-7
No files found.
MyApplication/app/src/main/AndroidManifest.xml
View file @
c6de924c
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
android:theme=
"@style/Theme.MyApplication"
android:theme=
"@style/Theme.MyApplication"
tools:targetApi=
"31"
>
tools:targetApi=
"31"
>
<activity
<activity
android:name=
".
Login
Activity"
android:name=
".
Home
Activity"
android:exported=
"true"
>
android:exported=
"true"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
MyApplication/app/src/main/java/com/example/myapplication/Database.java
View file @
c6de924c
This diff is collapsed.
Click to expand it.
MyApplication/app/src/main/java/com/example/myapplication/HomeActivity.java
View file @
c6de924c
package
com
.
example
.
myapplication
;
package
com
.
example
.
myapplication
;
import
android.annotation.SuppressLint
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.Button
;
...
@@ -19,7 +20,9 @@ public class HomeActivity extends AppCompatActivity {
...
@@ -19,7 +20,9 @@ public class HomeActivity extends AppCompatActivity {
private
Database
dbConnector
;
private
Database
dbConnector
;
private
List
<
String
>
bookingsList
;
// List to store all bookings
private
List
<
String
>
bookingsList
;
// List to store all bookings
private
int
ticketCount
;
@SuppressLint
(
"MissingInflatedId"
)
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
@@ -35,6 +38,7 @@ public class HomeActivity extends AppCompatActivity {
...
@@ -35,6 +38,7 @@ public class HomeActivity extends AppCompatActivity {
Button
addButton
=
findViewById
(
R
.
id
.
addButton
);
Button
addButton
=
findViewById
(
R
.
id
.
addButton
);
Button
searchButton
=
findViewById
(
R
.
id
.
searchButton
);
Button
searchButton
=
findViewById
(
R
.
id
.
searchButton
);
Button
showAllButton
=
findViewById
(
R
.
id
.
showAllButton
);
Button
showAllButton
=
findViewById
(
R
.
id
.
showAllButton
);
Button
updateButton
=
findViewById
(
R
.
id
.
updateButton
);
Button
deleteButton
=
findViewById
(
R
.
id
.
deleteButton
);
Button
deleteButton
=
findViewById
(
R
.
id
.
deleteButton
);
// Initialize the bookings list
// Initialize the bookings list
...
@@ -44,13 +48,13 @@ public class HomeActivity extends AppCompatActivity {
...
@@ -44,13 +48,13 @@ public class HomeActivity extends AppCompatActivity {
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
String
eventID
=
eventIDEditText
.
getText
().
toString
();
String
eventID
=
eventIDEditText
.
getText
().
toString
();
String
title
=
titleEditText
.
getText
().
toString
();
String
title
=
genreEditText
.
getText
().
toString
();
// Swap genreEditText and titleEditText
String
genre
=
genreEditText
.
getText
().
toString
();
String
genre
=
titleEditText
.
getText
().
toString
();
// Swap titleEditText and genreEditText
if
(
eventID
.
isEmpty
()
||
title
.
isEmpty
()
||
genre
.
isEmpty
())
{
if
(
eventID
.
isEmpty
()
||
title
.
isEmpty
()
||
genre
.
isEmpty
())
{
Toast
.
makeText
(
HomeActivity
.
this
,
"Please fill in all fields"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
HomeActivity
.
this
,
"Please fill in all fields"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
}
else
{
dbConnector
.
addBooking
(
eventID
,
title
,
genre
,
0
);
dbConnector
.
addBooking
(
eventID
,
title
,
genre
,
getTicketCount
()
);
Toast
.
makeText
(
HomeActivity
.
this
,
"Booking added successfully"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
HomeActivity
.
this
,
"Booking added successfully"
,
Toast
.
LENGTH_SHORT
).
show
();
// Clear the input fields after adding the booking
// Clear the input fields after adding the booking
...
@@ -76,7 +80,7 @@ public class HomeActivity extends AppCompatActivity {
...
@@ -76,7 +80,7 @@ public class HomeActivity extends AppCompatActivity {
showAllButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
showAllButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
bookingsList
=
dbConnector
.
searchBooking
();
bookingsList
=
dbConnector
.
getAllBookings
();
if
(
bookingsList
.
isEmpty
())
{
if
(
bookingsList
.
isEmpty
())
{
resultTextView
.
setText
(
"No bookings available"
);
resultTextView
.
setText
(
"No bookings available"
);
}
else
{
}
else
{
...
@@ -89,6 +93,22 @@ public class HomeActivity extends AppCompatActivity {
...
@@ -89,6 +93,22 @@ public class HomeActivity extends AppCompatActivity {
}
}
});
});
updateButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
String
eventID
=
eventIDEditText
.
getText
().
toString
();
String
newTitle
=
titleEditText
.
getText
().
toString
();
String
newGenre
=
genreEditText
.
getText
().
toString
();
dbConnector
.
updateBooking
(
eventID
,
newTitle
,
newGenre
);
Toast
.
makeText
(
HomeActivity
.
this
,
"Booking updated successfully"
,
Toast
.
LENGTH_SHORT
).
show
();
// Clear the input fields after updating the booking
eventIDEditText
.
setText
(
""
);
titleEditText
.
setText
(
""
);
genreEditText
.
setText
(
""
);
}
});
deleteButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
deleteButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
...
@@ -100,14 +120,49 @@ public class HomeActivity extends AppCompatActivity {
...
@@ -100,14 +120,49 @@ public class HomeActivity extends AppCompatActivity {
eventIDEditText
.
setText
(
""
);
eventIDEditText
.
setText
(
""
);
}
}
});
});
EditText
filterEditText
=
findViewById
(
R
.
id
.
filterEditText
);
Button
filterButton
=
findViewById
(
R
.
id
.
filterButton
);
filterButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
String
keyword
=
filterEditText
.
getText
().
toString
();
filterBookings
(
keyword
);
}
});
}
}
// Additional method to handle filter/search functionality
private
void
filterBookings
(
String
keyword
)
{
List
<
String
>
filteredList
=
new
ArrayList
<>();
for
(
String
booking
:
bookingsList
)
{
// Check if the booking genre contains the keyword
if
(
booking
.
toLowerCase
().
contains
(
keyword
.
toLowerCase
()))
{
filteredList
.
add
(
booking
);
}
}
if
(
filteredList
.
isEmpty
())
{
resultTextView
.
setText
(
"No matching bookings found"
);
}
else
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
booking
:
filteredList
)
{
sb
.
append
(
booking
).
append
(
"\n\n"
);
}
resultTextView
.
setText
(
sb
.
toString
());
}
}
private
void
displayTicketsForEvent
(
String
eventID
)
{
private
void
displayTicketsForEvent
(
String
eventID
)
{
String
tickets
=
dbConnector
.
getTicketsForEvent
(
eventID
);
List
<
String
>
ticketsList
=
dbConnector
.
getTicketsForEvent
(
eventID
);
if
(
tickets
==
null
)
{
if
(
tickets
List
.
isEmpty
()
)
{
resultTextView
.
setText
(
"No tickets available for this event"
);
resultTextView
.
setText
(
"No tickets available for this event"
);
}
else
{
}
else
{
resultTextView
.
setText
(
tickets
);
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
ticket
:
ticketsList
)
{
sb
.
append
(
ticket
).
append
(
"\n\n"
);
}
resultTextView
.
setText
(
sb
.
toString
());
}
}
}
}
...
@@ -116,4 +171,13 @@ public class HomeActivity extends AppCompatActivity {
...
@@ -116,4 +171,13 @@ public class HomeActivity extends AppCompatActivity {
super
.
onDestroy
();
super
.
onDestroy
();
dbConnector
.
close
();
dbConnector
.
close
();
}
}
public
void
setTicketCount
(
int
ticketCount
)
{
this
.
ticketCount
=
ticketCount
;
}
public
int
getTicketCount
()
{
return
ticketCount
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment