diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 66b9083..724b241 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -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")
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 766f0c7..1187fdc 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -16,7 +16,7 @@
android:name=".ChairList"
android:screenOrientation="portrait"
android:exported="false" />
-
): RecyclerView.Adapter() {
private lateinit var mListener : onItemClickListener
+ private val selectedItems = ArrayList()
+
+ 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): 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): RecyclerView.Adapter
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
- holder.chair.text=item[position].noAsiento.toString()
+ //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)
+ }
}
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/pantallacompra/ChairList.kt b/app/src/main/java/com/example/pantallacompra/ChairList.kt
index 6843e77..8d02676 100644
--- a/app/src/main/java/com/example/pantallacompra/ChairList.kt
+++ b/app/src/main/java/com/example/pantallacompra/ChairList.kt
@@ -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
+ private lateinit var seleccionados : ArrayList
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()
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)
}
})
diff --git a/app/src/main/java/com/example/pantallacompra/Event.kt b/app/src/main/java/com/example/pantallacompra/Event.kt
index 4b13032..86fc88b 100644
--- a/app/src/main/java/com/example/pantallacompra/Event.kt
+++ b/app/src/main/java/com/example/pantallacompra/Event.kt
@@ -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){
}
diff --git a/app/src/main/java/com/example/pantallacompra/EventList.kt b/app/src/main/java/com/example/pantallacompra/EventList.kt
index 500c2c0..df4c4f5 100644
--- a/app/src/main/java/com/example/pantallacompra/EventList.kt
+++ b/app/src/main/java/com/example/pantallacompra/EventList.kt
@@ -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) {
diff --git a/app/src/main/java/com/example/pantallacompra/MyAdapter.kt b/app/src/main/java/com/example/pantallacompra/MyAdapter.kt
index b6fd52a..7697fa8 100644
--- a/app/src/main/java/com/example/pantallacompra/MyAdapter.kt
+++ b/app/src/main/java/com/example/pantallacompra/MyAdapter.kt
@@ -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) : RecyclerView.Adapter(){
+
+class MyAdapter (private val eventList : ArrayList, private val context: Context ) : RecyclerView.Adapter(){
private lateinit var mListener : onItemClickListener
+
interface onItemClickListener{
fun onItemClick(position: Int)
}
@@ -29,16 +34,19 @@ class MyAdapter (private val eventList : ArrayList) : 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)
diff --git a/app/src/main/java/com/example/pantallacompra/compra.kt b/app/src/main/java/com/example/pantallacompra/compra.kt
new file mode 100644
index 0000000..8e750af
--- /dev/null
+++ b/app/src/main/java/com/example/pantallacompra/compra.kt
@@ -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)
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/boton_redondo.xml b/app/src/main/res/drawable/boton_redondo.xml
index 4ef9c75..b3b7e3f 100644
--- a/app/src/main/res/drawable/boton_redondo.xml
+++ b/app/src/main/res/drawable/boton_redondo.xml
@@ -1,6 +1,6 @@
-
+
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_chair_list.xml b/app/src/main/res/layout/activity_chair_list.xml
index e061ed4..3ddd335 100644
--- a/app/src/main/res/layout/activity_chair_list.xml
+++ b/app/src/main/res/layout/activity_chair_list.xml
@@ -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 @@
@@ -66,4 +67,42 @@
app:layout_constraintStart_toEndOf="@+id/noSalaText"
app:layout_constraintTop_toBottomOf="@+id/eventTextTitle" />
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_event_list.xml b/app/src/main/res/layout/activity_event_list.xml
index b5f304b..a75d4e4 100644
--- a/app/src/main/res/layout/activity_event_list.xml
+++ b/app/src/main/res/layout/activity_event_list.xml
@@ -2,6 +2,7 @@
@@ -23,8 +24,8 @@
diff --git a/app/src/main/res/layout/pantallacompra.xml b/app/src/main/res/layout/pantallacompra.xml
index 2833529..3ac9a33 100644
--- a/app/src/main/res/layout/pantallacompra.xml
+++ b/app/src/main/res/layout/pantallacompra.xml
@@ -12,7 +12,7 @@
+
+
@@ -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" />
-