Final Commit
This commit is contained in:
parent
bc572854f5
commit
bb81c7e63a
|
@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import com.google.firebase.database.DatabaseReference
|
||||
import com.google.firebase.database.FirebaseDatabase
|
||||
|
||||
class ChairAdapter (private val item : ArrayList<Asiento>): RecyclerView.Adapter<ChairAdapter.ViewHolder>() {
|
||||
class ChairAdapter (private val item : ArrayList<Asiento>, private val asientoNombre : String?): RecyclerView.Adapter<ChairAdapter.ViewHolder>() {
|
||||
|
||||
private lateinit var mListener : onItemClickListener
|
||||
private lateinit var database: FirebaseDatabase
|
||||
|
@ -22,7 +22,7 @@ class ChairAdapter (private val item : ArrayList<Asiento>): RecyclerView.Adapter
|
|||
|
||||
var asiento=item[position].noAsiento.toString()
|
||||
database = FirebaseDatabase.getInstance()
|
||||
var myRef = database.getReference("Asientos/$asiento/status")
|
||||
var myRef = database.getReference("$asientoNombre/$asiento/status")
|
||||
|
||||
val asientoprueba = item[position]
|
||||
val asientoNo = asientoprueba.noAsiento.toString()
|
||||
|
@ -68,9 +68,14 @@ class ChairAdapter (private val item : ArrayList<Asiento>): RecyclerView.Adapter
|
|||
val item = item[position]
|
||||
chair.text= item.noAsiento.toString()
|
||||
|
||||
if (selectedItems.contains(position)) {
|
||||
itemView.setBackgroundColor(Color.RED)
|
||||
if (item.status == "Ocupado") {
|
||||
itemView.setBackgroundColor(Color.RED) // Color para elementos ocupados
|
||||
} else if (selectedItems.contains(position)) {
|
||||
itemView.setBackgroundColor(Color.BLUE)
|
||||
selectedItems.add(position)
|
||||
|
||||
} else {
|
||||
selectedItems.remove(position)
|
||||
itemView.setBackgroundColor(Color.parseColor("#4a8a9e"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ class ChairList : AppCompatActivity() {
|
|||
eventList = arrayListOf<Asiento>()
|
||||
// chairs= arrayListOf<String>()
|
||||
|
||||
getEvents()
|
||||
getEvents(nombreEvento)
|
||||
btnComprar.setOnClickListener{
|
||||
val adapter = recycleView.adapter as ChairAdapter
|
||||
val asientosOcupados = adapter.getOccupiedSeats()
|
||||
|
@ -57,6 +57,7 @@ class ChairList : AppCompatActivity() {
|
|||
val montoTotal = asientosOcupados.size * 50
|
||||
intent.putStringArrayListExtra("asientosSeleccionados", ArrayList(asientosOcupados))
|
||||
intent.putExtra("montoTotal", montoTotal)
|
||||
intent.putExtra("nombreEvento",nombreEvento.toString())
|
||||
startActivity(intent)
|
||||
|
||||
val mensajeToast = if (asientosOcupados.isNotEmpty()) {
|
||||
|
@ -73,8 +74,8 @@ class ChairList : AppCompatActivity() {
|
|||
}
|
||||
|
||||
}
|
||||
private fun getEvents(){
|
||||
dbreference= FirebaseDatabase.getInstance().getReference("Asientos")
|
||||
private fun getEvents(nombreEvento: String?){
|
||||
dbreference= FirebaseDatabase.getInstance().getReference("$nombreEvento")
|
||||
dbreference.addValueEventListener(object : ValueEventListener {
|
||||
override fun onDataChange(snapshot: DataSnapshot) {
|
||||
if(snapshot.exists()){
|
||||
|
@ -83,7 +84,7 @@ class ChairList : AppCompatActivity() {
|
|||
val item=event.getValue(Asiento::class.java)
|
||||
eventList.add(item!!)
|
||||
}
|
||||
var adapter=ChairAdapter(eventList)
|
||||
var adapter=ChairAdapter(eventList, "$nombreEvento")
|
||||
recycleView.adapter=adapter
|
||||
|
||||
adapter.setOnItemClickListener(object : ChairAdapter.onItemClickListener{
|
||||
|
@ -93,7 +94,7 @@ class ChairList : AppCompatActivity() {
|
|||
|
||||
})
|
||||
// total= adapter.getTotal()
|
||||
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,15 +15,30 @@ class MainActivity : AppCompatActivity() {
|
|||
private lateinit var eventosReferences : DatabaseReference
|
||||
private lateinit var salasReference: DatabaseReference
|
||||
private lateinit var asientosReference: DatabaseReference
|
||||
private lateinit var champinosReference: DatabaseReference
|
||||
private lateinit var caligarisReference: DatabaseReference
|
||||
private lateinit var rhianaReference: DatabaseReference
|
||||
private lateinit var mjReference: DatabaseReference
|
||||
private lateinit var potrosReference: DatabaseReference
|
||||
private lateinit var europaReference: DatabaseReference
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding= ActivityMainBinding.inflate(layoutInflater)
|
||||
eventosReferences= FirebaseDatabase.getInstance().getReference("Eventos")
|
||||
salasReference= FirebaseDatabase.getInstance().getReference("Salas")
|
||||
asientosReference= FirebaseDatabase.getInstance().getReference("Asientos")
|
||||
champinosReference= FirebaseDatabase.getInstance().getReference("Champions")
|
||||
rhianaReference= FirebaseDatabase.getInstance().getReference("Rhiana Show")
|
||||
mjReference= FirebaseDatabase.getInstance().getReference("Michael Jackson")
|
||||
caligarisReference= FirebaseDatabase.getInstance().getReference("Los caligaris")
|
||||
potrosReference= FirebaseDatabase.getInstance().getReference("Potros Furiosos")
|
||||
europaReference= FirebaseDatabase.getInstance().getReference("Europa League")
|
||||
|
||||
setContentView(R.layout.activity_main)
|
||||
cargarAsientos(asientosReference)
|
||||
cargarAsientos(europaReference)
|
||||
cargarAsientos(potrosReference)
|
||||
|
||||
|
||||
val boton = findViewById<Button>(R.id.nextBtn)
|
||||
|
||||
|
|
|
@ -4,13 +4,21 @@ import android.content.Intent
|
|||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.bumptech.glide.Glide
|
||||
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 compra: AppCompatActivity() {
|
||||
private lateinit var dbreference : DatabaseReference
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.pantallacompra)
|
||||
|
@ -27,10 +35,33 @@ class compra: AppCompatActivity() {
|
|||
|
||||
// Obtener la lista de asientos seleccionados del intent
|
||||
val asientosSeleccionados = intent.getStringArrayListExtra("asientosSeleccionados")
|
||||
|
||||
val bundle = intent.extras
|
||||
var nombreEvento=bundle?.getString("nombreEvento")
|
||||
var imageEvent : ImageView = findViewById(R.id.imgEvento)
|
||||
// Mostrar la lista de asientos seleccionados en el TextView
|
||||
textViewAsientos.text = asientosSeleccionados?.joinToString(", ")
|
||||
textViewMontoTotal.text = "$montoTotal pesos"
|
||||
textViewMontoTotal.text = "$ $montoTotal"
|
||||
|
||||
dbreference= FirebaseDatabase.getInstance().getReference("Eventos/$nombreEvento")
|
||||
dbreference.addValueEventListener(object : ValueEventListener {
|
||||
override fun onDataChange(dataSnapshot: DataSnapshot) {
|
||||
if (dataSnapshot.exists()) {
|
||||
val imageUrl = dataSnapshot.child("urlImage").value.toString()
|
||||
// Cargar la imagen en el ImageView usando una biblioteca como Glide o Picasso
|
||||
Glide.with(this@compra)
|
||||
.load(imageUrl)
|
||||
.into(imageEvent)
|
||||
} else {
|
||||
// Manejar el caso en que no se encuentre la imagen
|
||||
println("No se encontró la URL de la imagen en la base de datos")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCancelled(databaseError: DatabaseError) {
|
||||
// Manejar cualquier error de base de datos
|
||||
println("Error al obtener la URL de la imagen: ${databaseError.message}")
|
||||
}
|
||||
})
|
||||
|
||||
btnComprar.setOnClickListener {
|
||||
val nombre = editTextNombre.text.toString()
|
||||
|
|
|
@ -34,11 +34,10 @@
|
|||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/chairRecycleView"
|
||||
android:layout_width="375dp"
|
||||
android:layout_height="299dp"
|
||||
android:layout_marginTop="76dp"
|
||||
android:layout_width="309dp"
|
||||
android:layout_height="155dp"
|
||||
android:layout_marginTop="176dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.444"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/eventTextTitle" />
|
||||
|
||||
|
@ -49,12 +48,10 @@
|
|||
android:text="N0. Sala"
|
||||
android:textAlignment="center"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/chairRecycleView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="parent"
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/logoCamion" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/eventoText"
|
||||
|
@ -118,7 +115,7 @@
|
|||
android:id="@+id/textView8"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="130dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginTop="56dp"
|
||||
android:background="#612020"
|
||||
android:fontFamily="@font/cinepolis"
|
||||
android:gravity="center"
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
app:layout_constraintTop_toBottomOf="@+id/top_layout">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:id="@+id/imgEvento"
|
||||
android:layout_width="345dp"
|
||||
android:layout_height="328dp"
|
||||
android:scaleType="centerCrop"
|
||||
|
@ -87,7 +87,7 @@
|
|||
android:background="#297880"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/top_layout"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/top_layout"
|
||||
app:layout_constraintTop_toBottomOf="@+id/second_layout">
|
||||
|
||||
|
@ -106,26 +106,18 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Fecha y hora: "
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintStart_toStartOf="@id/textView3"
|
||||
app:layout_constraintTop_toBottomOf="@id/textView3" />
|
||||
|
||||
<!-- TextView para "Asientos seleccionados" -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="19dp"
|
||||
android:text="Asientos seleccionados: "
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintStart_toStartOf="@id/textView3"
|
||||
app:layout_constraintTop_toBottomOf="@id/textView4" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView3" />
|
||||
|
||||
<!-- TextView para "Monto total" -->
|
||||
<TextView
|
||||
|
@ -148,25 +140,16 @@
|
|||
app:layout_constraintStart_toStartOf="@id/textView6"
|
||||
app:layout_constraintTop_toBottomOf="@id/textView6" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4Result"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="13 de Noviembre, 4:00 AM"
|
||||
android:textColor="#4CAF50"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintStart_toEndOf="@id/textView4"
|
||||
app:layout_constraintTop_toTopOf="@id/textView4" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView5Result"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="19dp"
|
||||
android:text="A1, B2 "
|
||||
android:textColor="#4CAF50"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintStart_toEndOf="@id/textView5"
|
||||
app:layout_constraintTop_toTopOf="@id/textView5" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6Result"
|
||||
|
@ -214,13 +197,14 @@
|
|||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:backgroundTint="#D9D9D9"
|
||||
android:text="Cancelar"
|
||||
android:fontFamily="@font/cinepolis"
|
||||
android:text="Cancelar"
|
||||
android:textColor="#000000"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/buttonComprar"
|
||||
app:layout_constraintTop_toBottomOf="@id/editTextTelefono" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonComprar"
|
||||
android:layout_width="0dp"
|
||||
|
@ -228,8 +212,8 @@
|
|||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:backgroundTint="#D9D9D9"
|
||||
android:text="Comprar"
|
||||
android:fontFamily="@font/cinepolis"
|
||||
android:text="Comprar"
|
||||
android:textColor="#000000"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintEnd_toStartOf="@id/buttonCancelar"
|
||||
|
|
Loading…
Reference in New Issue