Hala Madrid

This commit is contained in:
sebastiancc27 2024-03-11 23:11:30 -06:00
parent b40f77c819
commit 926e19d44d
14 changed files with 332 additions and 1 deletions

1
.idea/.name Normal file
View File

@ -0,0 +1 @@
pantallaCompra

View File

@ -1,6 +1,7 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.google.gms.google-services")
}
android {
@ -33,6 +34,10 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
viewBinding = true
}
}
dependencies {
@ -41,6 +46,7 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("com.google.firebase:firebase-database:20.3.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

49
app/google-services.json Normal file
View File

@ -0,0 +1,49 @@
{
"project_info": {
"project_number": "466470867685",
"firebase_url": "https://playpal-853fb-default-rtdb.firebaseio.com",
"project_id": "playpal-853fb",
"storage_bucket": "playpal-853fb.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:466470867685:android:0ff8f84509e25132ae3a0c",
"android_client_info": {
"package_name": "com.example.pantallacompra"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyDq4DgG2Re5v10N9-xJAKiiSQ6OphC7uKM"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:466470867685:android:1205ac64994853dfae3a0c",
"android_client_info": {
"package_name": "com.example.teatro2"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyDq4DgG2Re5v10N9-xJAKiiSQ6OphC7uKM"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}

View File

@ -0,0 +1,5 @@
package com.example.pantallacompra
data class Asiento(val noAsiento : String?=null, val precio : Int?=null, val tipo : String ?=null, val status : String?=null, val nSala : Int?=null){
}

View File

@ -0,0 +1,41 @@
package com.example.pantallacompra
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
class ChairAdapter (private val item : ArrayList<Asiento>): RecyclerView.Adapter<ChairAdapter.ViewHolder>() {
private lateinit var mListener : onItemClickListener
interface onItemClickListener{
fun onItemClick(position: Int)
}
fun setOnItemClickListener(listener: onItemClickListener){
mListener=listener
}
class ViewHolder(itemView: View, listener: onItemClickListener): RecyclerView.ViewHolder(itemView){
val chair : TextView = itemView.findViewById(R.id.chair)
init {
itemView.setOnClickListener{
listener.onItemClick(adapterPosition)
}
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.chair_item,parent,false),mListener)
}
override fun getItemCount(): Int {
return item.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.chair.text=item[position].noAsiento.toString()
}
}

View File

@ -0,0 +1,73 @@
package com.example.pantallacompra
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import android.widget.Toast
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ValueEventListener
class ChairList : AppCompatActivity() {
private lateinit var dbreference : DatabaseReference
private lateinit var recycleView: RecyclerView
private lateinit var eventList : ArrayList<Asiento>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_chair_list)
//SE GUARDA EL NOMBRE DEL EVENTO
val bundle= intent.extras
val nombreEvento=bundle?.getString("nombreEvento")
val noSala=bundle?.getString("sala")
val nEvento:TextView =findViewById(R.id.eventoText)
nEvento.text=nombreEvento
val nSala:TextView=findViewById(R.id.noSalaText)
nSala.text=noSala
recycleView = findViewById(R.id.chairRecycleView)
recycleView.layoutManager = GridLayoutManager(this,2)
recycleView.setHasFixedSize(true)
eventList = arrayListOf<Asiento>()
getEvents()
}
private fun getEvents(){
dbreference= FirebaseDatabase.getInstance().getReference("Asientos")
dbreference.addValueEventListener(object : ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {
if(snapshot.exists()){
for(event in snapshot.children){
val item=event.getValue(Asiento::class.java)
eventList.add(item!!)
}
var adapter=ChairAdapter(eventList)
recycleView.adapter=adapter
adapter.setOnItemClickListener(object : ChairAdapter.onItemClickListener{
override fun onItemClick(position: Int) {
//Toast.makeText(this@ChairList,"Has hecho click", Toast.LENGTH_LONG).show()
}
})
}
}
override fun onCancelled(error: DatabaseError) {
TODO("Not yet implemented")
}
})
}
}

View File

@ -0,0 +1,5 @@
package com.example.pantallacompra
data class Event(val nombre : String ?=null, val genero : String ?=null, val duracion : Int ?=null, val tipo : String ?=null){
}

View File

@ -0,0 +1,68 @@
package com.example.pantallacompra
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ValueEventListener
class EventList : AppCompatActivity() {
private lateinit var dbreference : DatabaseReference
private lateinit var recycleView: RecyclerView
private lateinit var eventList : ArrayList<Event>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_event_list)
recycleView = findViewById(R.id.eventRecycleView)
recycleView.layoutManager = LinearLayoutManager(this)
recycleView.setHasFixedSize(true)
eventList = arrayListOf<Event>()
getEvents()
}
private fun getEvents(){
dbreference= FirebaseDatabase.getInstance().getReference("Eventos")
dbreference.addValueEventListener(object : ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {
if(snapshot.exists()){
for(event in snapshot.children){
val item=event.getValue(Event::class.java)
eventList.add(item!!)
}
//recycleView.adapter=MyAdapter(eventList)
var adapter=MyAdapter(eventList)
recycleView.adapter=adapter
adapter.setOnItemClickListener(object : MyAdapter.onItemClickListener{
override fun onItemClick(position: Int) {
//Toast.makeText(this@EventList,"${eventList[position].nombre.toString()}", Toast.LENGTH_LONG).show()
val nombreEvento: String= eventList[position].nombre.toString()
var salaEvento:String?=null
when(nombreEvento){
"Champions"-> salaEvento = "1"
"Los caligaris"->salaEvento="2"
}
val intent = Intent(this@EventList, ChairList::class.java)
intent.putExtra("nombreEvento",nombreEvento)//CLAVE : VALOR
intent.putExtra("sala",salaEvento)
startActivity(intent)
}
})
}
}
override fun onCancelled(error: DatabaseError) {
TODO("Not yet implemented")
}
})
}
}

View File

@ -6,13 +6,15 @@ import android.os.Bundle
import android.widget.Button
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.pantallacompra.databinding.ActivityMainBinding
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
private lateinit var eventosReferences : DatabaseReference
private lateinit var salasReference: DatabaseReference
private lateinit var asientosReference: DatabaseReference
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding= ActivityMainBinding.inflate(layoutInflater)

View File

@ -0,0 +1,49 @@
package com.example.pantallacompra
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
class MyAdapter (private val eventList : ArrayList<Event>) : RecyclerView.Adapter<MyAdapter.MyViewHolder>(){
private lateinit var mListener : onItemClickListener
interface onItemClickListener{
fun onItemClick(position: Int)
}
fun setOnItemClickListener(listener: onItemClickListener){
mListener=listener
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
val itemView= LayoutInflater.from(parent.context).inflate(R.layout.event_item,parent,false)
return MyViewHolder(itemView, mListener)
}
override fun getItemCount(): Int {
return eventList.size
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
val list= eventList[position]
holder.nombre.text="Evento:" +list.nombre
holder.tipo.text="Tipo: "+list.tipo
holder.duracion.text="Duración: "+list.duracion.toString()+" min"
}
class MyViewHolder(itemView : View, listener: onItemClickListener): RecyclerView.ViewHolder(itemView){
val nombre : TextView = itemView.findViewById(R.id.eventName)
val tipo: TextView = itemView.findViewById(R.id.eventType)
val duracion: TextView =itemView.findViewById(R.id.eventDuration)
init {
itemView.setOnClickListener{
listener.onItemClick(adapterPosition)
}
}
}
}

View File

@ -0,0 +1,5 @@
package com.example.pantallacompra
data class Sala(val n0Sala : Int?=null, val nombreEvento : String ?=null){
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f0f0f0"></solid>
<corners android:radius="20dp"></corners>
<stroke android:color="#02161c" android:width="2dp"></stroke>
</shape>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_margin="16dp"
android:background="#225c6e">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/chair"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,3 +1,8 @@
buildscript {
dependencies {
classpath("com.google.gms:google-services:4.4.1")
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.2.2" apply false