Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/src/main/java/com/example/pantallacompra/MainActivity.kt
This commit is contained in:
Maxch26 2024-03-18 14:34:02 -06:00
commit aee306ac26
13 changed files with 172 additions and 32 deletions

View File

@ -47,6 +47,8 @@ dependencies {
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")
implementation ("com.github.bumptech.glide:glide:4.13.0")
annotationProcessor ("com.github.bumptech.glide:compiler:4.12.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

View File

@ -16,7 +16,7 @@
android:name=".ChairList"
android:screenOrientation="portrait"
android:exported="false" />
<activity android:name=".PantallaCompra"
<activity android:name=".compra"
android:screenOrientation="portrait"
android:exported="false" />
<activity

View File

@ -1,5 +1,6 @@
package com.example.pantallacompra
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -9,6 +10,16 @@ import androidx.recyclerview.widget.RecyclerView
class ChairAdapter (private val item : ArrayList<Asiento>): RecyclerView.Adapter<ChairAdapter.ViewHolder>() {
private lateinit var mListener : onItemClickListener
private val selectedItems = ArrayList<Int>()
fun toggleSelection(position: Int) {
if (selectedItems.contains(position)) {
selectedItems.remove(position)
} else {
selectedItems.add(position)
}
notifyItemChanged(position)
}
interface onItemClickListener{
fun onItemClick(position: Int)
@ -22,7 +33,10 @@ class ChairAdapter (private val item : ArrayList<Asiento>): RecyclerView.Adapter
val chair : TextView = itemView.findViewById(R.id.chair)
init {
itemView.setOnClickListener{
listener.onItemClick(adapterPosition)
val position=adapterPosition
if(position!=RecyclerView.NO_POSITION){
(itemView.context as? ChairAdapter) ?.toggleSelection((position))
}
}
}
}
@ -36,6 +50,19 @@ class ChairAdapter (private val item : ArrayList<Asiento>): RecyclerView.Adapter
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
//holder.chair.text=item[position].noAsiento.toString()
// val chair = item[position]
holder.chair.text = item[position].noAsiento.toString()
if (selectedItems.contains(position)) {
holder.itemView.setBackgroundColor(Color.RED)
} else {
holder.itemView.setBackgroundColor(Color.parseColor("#225c6e"))
}
holder.itemView.setOnClickListener {
toggleSelection(position)
}
}
}

View File

@ -1,11 +1,13 @@
package com.example.pantallacompra
import androidx.appcompat.app.AppCompatActivity
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
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
@ -17,6 +19,7 @@ class ChairList : AppCompatActivity() {
private lateinit var dbreference : DatabaseReference
private lateinit var recycleView: RecyclerView
private lateinit var eventList : ArrayList<Asiento>
private lateinit var seleccionados : ArrayList<String>
override fun onCreate(savedInstanceState: Bundle?) {
@ -34,13 +37,26 @@ class ChairList : AppCompatActivity() {
val nSala:TextView=findViewById(R.id.noSalaText)
nSala.text=noSala
val btnConfirmar:Button = findViewById(R.id.btnConfirmar)
val btnCancelar:Button = findViewById(R.id.btncancelar)
recycleView = findViewById(R.id.chairRecycleView)
recycleView.layoutManager = GridLayoutManager(this,2)
recycleView.layoutManager = GridLayoutManager(this,4)
recycleView.setHasFixedSize(true)
eventList = arrayListOf<Asiento>()
getEvents()
btnConfirmar.setOnClickListener(View.OnClickListener() {
val intent = Intent(this, compra::class.java)
startActivity(intent)
})
btnCancelar.setOnClickListener(View.OnClickListener() {
val intent = Intent(this, EventList::class.java)
startActivity(intent)
})
}
private fun getEvents(){
dbreference= FirebaseDatabase.getInstance().getReference("Asientos")
@ -54,9 +70,10 @@ class ChairList : AppCompatActivity() {
}
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()
adapter.toggleSelection(position)
}
})

View File

@ -1,5 +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){
data class Event(val nombre : String ?=null, val genero : String ?=null, val duracion : Int ?=null, val tipo : String ?=null, val urlImage : String ?=null){
}

View File

@ -37,7 +37,7 @@ class EventList : AppCompatActivity() {
eventList.add(item!!)
}
//recycleView.adapter=MyAdapter(eventList)
var adapter=MyAdapter(eventList)
var adapter=MyAdapter(eventList, this@EventList)
recycleView.adapter=adapter
adapter.setOnItemClickListener(object : MyAdapter.onItemClickListener{
override fun onItemClick(position: Int) {

View File

@ -1,15 +1,20 @@
package com.example.pantallacompra
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
class MyAdapter (private val eventList : ArrayList<Event>) : RecyclerView.Adapter<MyAdapter.MyViewHolder>(){
class MyAdapter (private val eventList : ArrayList<Event>, private val context: Context ) : RecyclerView.Adapter<MyAdapter.MyViewHolder>(){
private lateinit var mListener : onItemClickListener
interface onItemClickListener{
fun onItemClick(position: Int)
}
@ -29,16 +34,19 @@ class MyAdapter (private val eventList : ArrayList<Event>) : RecyclerView.Adapte
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
val list= eventList[position]
val imageUrl=eventList[position].urlImage
holder.nombre.text="Evento:" +list.nombre
holder.tipo.text="Tipo: "+list.tipo
holder.duracion.text="Duración: "+list.duracion.toString()+" min"
Glide.with(context).load(imageUrl).into(holder.imagen)
}
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)
val imagen: ImageView =itemView.findViewById(R.id.imageEvent)
init {
itemView.setOnClickListener{
listener.onItemClick(adapterPosition)

View File

@ -0,0 +1,37 @@
package com.example.pantallacompra
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
class compra: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.pantallacompra)
val btnCancelar: Button = findViewById(R.id.buttonCancelar)
val editTextNombre: EditText = findViewById(R.id.editTextNombre)
val editTextTelefono: EditText = findViewById(R.id.editTextTelefono)
val btnComprar: Button = findViewById(R.id.buttonComprar)
btnComprar.setOnClickListener {
val nombre = editTextNombre.text.toString()
val telefono = editTextTelefono.text.toString()
if (nombre.isNotEmpty() && telefono.isNotEmpty()) {
val mensaje = "Nombre: $nombre\nTeléfono: $telefono"
Toast.makeText(this, mensaje, Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(this, "Por favor, ingrese su nombre y número de teléfono", Toast.LENGTH_SHORT).show()
}
}
btnCancelar.setOnClickListener {
val intent = Intent(this, EventList::class.java)
startActivity(intent)
}
}
}

View File

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

View File

@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="#2B7F88"
android:layout_height="match_parent"
tools:context=".MainActivity">
@ -32,11 +33,11 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/chairRecycleView"
android:layout_width="401dp"
android:layout_height="582dp"
android:layout_width="374dp"
android:layout_height="499dp"
android:layout_marginTop="60dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintHorizontal_bias="0.567"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/eventTextTitle" />
@ -66,4 +67,42 @@
app:layout_constraintStart_toEndOf="@+id/noSalaText"
app:layout_constraintTop_toBottomOf="@+id/eventTextTitle" />
<LinearLayout
android:layout_width="409dp"
android:layout_height="81dp"
android:layout_marginTop="502dp"
android:layout_marginEnd="2dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/chairRecycleView">
<Button
android:id="@+id/btncancelar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="#D9D9D9"
android:text="Cancelar"
android:fontFamily="@font/cinepolis"
android:textColor="#000000"
android:layout_marginTop="15dp"
android:layout_marginLeft="4dp"
android:textSize="18dp" />
<Button
android:id="@+id/btnConfirmar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginRight="4dp"
android:layout_weight="1"
android:backgroundTint="#D9D9D9"
android:fontFamily="@font/cinepolis"
android:text="Confirmar"
android:textColor="#000000"
android:textSize="18dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -2,6 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="#2B7F88"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".EventList">
@ -23,8 +24,8 @@
<ImageView
android:id="@+id/logoCamion"
android:layout_width="120dp"
android:layout_height="86dp"
android:layout_width="102dp"
android:layout_height="85dp"
android:background="#08404F"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
@ -50,6 +51,7 @@
android:background="#297880"
android:fontFamily="@font/cinepolis"
android:text="Eventos"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="30sp"

View File

@ -9,6 +9,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/chair"
android:textColor="#FFFFFF"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
/>

View File

@ -12,7 +12,7 @@
<!-- Primer ConstraintLayout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/top_layout"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#08404F"
app:layout_constraintEnd_toEndOf="parent"
@ -25,9 +25,11 @@
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PLAYPAL"
android:fontFamily="@font/cinepolis"
android:gravity="center"
android:text="Playpal"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:textSize="50sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
@ -37,9 +39,8 @@
<ImageView
android:id="@+id/imageView2"
android:layout_width="29dp"
android:layout_height="27dp"
android:layout_marginStart="4dp"
android:layout_width="120dp"
android:layout_height="86dp"
android:layout_marginTop="3dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -50,13 +51,18 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- Segundo ConstraintLayout -->
<!-- Tercer ConstraintLayout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/second_layout"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#08404F"
android:background="#297880"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/third_layout"
app:layout_constraintEnd_toEndOf="@+id/top_layout"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/top_layout"
app:layout_constraintTop_toBottomOf="@+id/top_layout">
@ -69,16 +75,16 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- Tercer ConstraintLayout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/third_layout"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#08404F"
android:background="#297880"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/top_layout"
app:layout_constraintHorizontal_bias="1.0"
@ -91,7 +97,9 @@
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginStart="16dp"
android:layout_marginTop="4dp"
android:gravity="center"
android:text="DETALLES DE LA VENTA"
android:textColor="#FFFFFF"
android:textSize="16sp"
@ -205,8 +213,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:background="#d9d9d9"
android:backgroundTint="#0D9D9D"
android:backgroundTint="#D9D9D9"
android:text="Comprar"
android:textColor="#000000"
android:textSize="10sp"
@ -220,7 +227,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:background="#d9d9d9"
android:backgroundTint="#D9D9D9"
android:text="Cancelar"
android:textColor="#000000"
android:textSize="10sp"