diff --git a/TolucaGraphics - copia/.idea/.name b/TolucaGraphics - copia/.idea/.name
new file mode 100644
index 0000000..917bb28
--- /dev/null
+++ b/TolucaGraphics - copia/.idea/.name
@@ -0,0 +1 @@
+TolucaGraphics
\ No newline at end of file
diff --git a/TolucaGraphics - copia/.idea/vcs.xml b/TolucaGraphics - copia/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/TolucaGraphics - copia/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/ClassRandom.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/ClassRandom.kt
new file mode 100644
index 0000000..2ef50b2
--- /dev/null
+++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/ClassRandom.kt
@@ -0,0 +1,14 @@
+package com.example.tolucagraphics
+
+import android.view.View
+import android.widget.TextView
+import okhttp3.WebSocket
+import okhttp3.WebSocketListener
+
+class ClassRandom :WebSocketListener() {
+ override fun onMessage(webSocket: WebSocket, text: String) {
+ super.onMessage(webSocket, text)
+ var view : View?=null
+ view?.findViewById(R.id.textID)
+ }
+}
\ No newline at end of file
diff --git a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/KeysWebSocket.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/KeysWebSocket.kt
new file mode 100644
index 0000000..0645d5e
--- /dev/null
+++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/KeysWebSocket.kt
@@ -0,0 +1,16 @@
+package com.example.tolucagraphics
+
+object KeysWebSocket {
+ const val commandResponse = "COMMAND_RESPONSE"
+ const val trucoRoomEvent = "TRUCO_ROOM_EVENT"
+ const val trucoTableEvent = "TRUCO_TABLE_EVENT"
+ const val tablePositionSetted = "TABLE_POSITION_SETTED"
+ const val roomUserJoined = "ROOM_USER_JOINED"
+ const val roomLeftRoom = "USER_LEFT_ROOM"
+ const val roomTableCreated = "ROOM_TABLE_CREATED"
+ const val roomTableUserJoined = "ROOM_TABLE_USER_JOINED"
+ const val commandGetRooms = "get_rooms"
+ const val commandJoinRoom = "join_room"
+ const val commandCreateRoomTable = "create_room_table"
+
+}
\ No newline at end of file
diff --git a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/LobbyActivity.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/LobbyActivity.kt
index 419822f..8ffb04d 100644
--- a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/LobbyActivity.kt
+++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/LobbyActivity.kt
@@ -8,7 +8,7 @@ import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.example.tolucagraphics.datas.GetRooms
-import com.example.tolucagraphics.events.Events
+import com.example.tolucagraphics.events.EventGetRoom
import com.google.gson.Gson
import kotlinx.android.synthetic.main.activity_lobby.*
import okhttp3.*
@@ -16,12 +16,10 @@ import java.util.concurrent.TimeUnit
class LobbyActivity : AppCompatActivity(){
- val conection = Conection
+ val conection = Socket
private val SERVER_PATH = "ws://3.222.70.21:5000/ws?"
- lateinit var webSocket : WebSocket
var username : String? = null
private val gson = Gson()
- var eventReceived : Events?= null
lateinit var campoIDroom : TextView
lateinit var campotestNameRoom : TextView
@@ -77,12 +75,12 @@ class LobbyActivity : AppCompatActivity(){
Log.d("request", "Receiving : $text")
val gsonreceived = Gson()
runOnUiThread {
- eventReceived = gsonreceived.fromJson(text, Events::class.java)
+ val eventReceived = gsonreceived.fromJson(text, EventGetRoom::class.java)
campoIDroom = findViewById(R.id.campoID)
campotestNameRoom = findViewById(R.id.campoNAME)
if (eventReceived != null) {
- campoIDroom.text = eventReceived?.data?.rooms?.get(0)?.id ?: "0"
- campotestNameRoom.text = eventReceived?.data?.rooms?.get(0)?.name ?: "-"
+ campoIDroom.text = eventReceived.data?.rooms?.get(0)?.id ?: "0"
+ campotestNameRoom.text = eventReceived.data?.rooms?.get(0)?.name ?: "-"
}
}
}
@@ -93,23 +91,4 @@ class LobbyActivity : AppCompatActivity(){
Log.d("request","Error : " + t.message)
}
}
- object Conection{
- var username: String?= null
- var SERVER_PATH: String?= null
- val client = OkHttpClient.Builder()
- .readTimeout(1, TimeUnit.SECONDS)
- .build()
- var request : Request?=null
- var listener : WebSocketListener?=null
- fun realizarConex() {
- request = Request.Builder()
- .url(SERVER_PATH + username)
- .build()
- }
- var webSocketSingle : WebSocket?=null
- fun conectarconWS(){
- webSocketSingle = client.newWebSocket(request!!, listener!!)
-
- }
- }
}
\ No newline at end of file
diff --git a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MesaEnJuego.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MesaEnJuego.kt
new file mode 100644
index 0000000..f1cad02
--- /dev/null
+++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MesaEnJuego.kt
@@ -0,0 +1,48 @@
+package com.example.tolucagraphics
+
+import android.annotation.SuppressLint
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.util.Log
+import com.google.gson.Gson
+import okhttp3.Response
+import okhttp3.WebSocket
+import okhttp3.WebSocketListener
+
+class MesaEnJuego : AppCompatActivity() {
+ val single = Socket
+ val gson = Gson()
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_mesa_en_juego)
+ val intentJoin = intent.getStringExtra("join")!!
+ Log.d("TAG", "Join from Intent: $intentJoin")
+ //single.listener = Listener2()
+ single.conectarconWS()
+ }
+ fun mensajeRecibido(text : String){
+ Log.d("TAG", text)
+ }
+ inner class Listener2 : WebSocketListener(){
+ @SuppressLint("SetTextI18n")
+ override fun onMessage(webSocket: WebSocket, text: String) {
+ super.onMessage(webSocket, text)
+ runOnUiThread {
+ Log.d("TAG", "Undefined text -> $text")
+ /*if (text.contains(KeysWebSocket.commandResponse,true) && text.contains(KeysWebSocket.commandGetRooms)){
+ }*/
+ mensajeRecibido(text)
+ }
+ }
+
+ override fun onOpen(webSocket: WebSocket, response: Response) {
+ super.onOpen(webSocket, response)
+ Log.d("TAG", "established connection! Table Game!!! <3")
+ }
+
+ override fun onClosing(webSocket: WebSocket, code: Int, reason: String) {
+ super.onClosing(webSocket, code, reason)
+ Log.d("TAG", "$code $reason")
+ }
+ }
+}
diff --git a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MesasActivity.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MesasActivity.kt
index b1d908d..868e31f 100644
--- a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MesasActivity.kt
+++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MesasActivity.kt
@@ -1,53 +1,131 @@
package com.example.tolucagraphics
import android.annotation.SuppressLint
+import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
+import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
import com.example.tolucagraphics.adapters.JugadoresAdapter
-import com.example.tolucagraphics.datas.Data
-import com.example.tolucagraphics.datas.JoinData
-import com.example.tolucagraphics.datas.JoinTable
-import com.example.tolucagraphics.events.Events
-import com.example.tolucagraphics.events.UserElement
+import com.example.tolucagraphics.adapters.MesaAdapter
+import com.example.tolucagraphics.datas.CreateTable
+import com.example.tolucagraphics.datas.GetRooms
+import com.example.tolucagraphics.datas.JoinRoom
+import com.example.tolucagraphics.events.*
+import com.example.tolucagraphics.models.ModelForTables
import com.google.gson.Gson
import kotlinx.android.synthetic.main.activity_mesas_players.*
import okhttp3.Response
import okhttp3.WebSocket
import okhttp3.WebSocketListener
-import okio.ByteString
class MesasActivity : AppCompatActivity() {
var selector = 1
val gson = Gson()
val decoJson = Gson()
- var eventoRecibido = Events()
- private val conection2 = LobbyActivity.Conection
- private lateinit var adapterJugadores : JugadoresAdapter
+ private val conection = Socket
+ var yaEntro = false
+ var yaEntroMesaCreada = false
+ var tamanioJugadores = 0
+ var tamanioMesas = 0
+ var listaJugadores = ArrayList()
+ var listaMesas = ArrayList()
+ val listaTables = ArrayList()
+ lateinit var jugadoresAdapter: JugadoresAdapter
+ lateinit var mesasAdapter: MesaAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_mesas_players)
- conection2.webSocketSingle?.close(1000, "Change Activity")
- conection2.listener = TestListener()
- conection2.conectarconWS()
-
+ conection.webSocketSingle?.close(1000, "Change Activity")
+ conection.listener = TestListener()
+ conection.conectarconWS()
+ conection.webSocketSingle?.send(gson.toJson(GetRooms()))
+ conection.webSocketSingle?.send(gson.toJson(JoinRoom()))
+ btnCreaMesa.setOnClickListener {
+ conection.webSocketSingle?.send(gson.toJson(CreateTable()))
+ }
/********************PETICION DE MESAS******************/
- val joinRoom = JoinData("join_room", Data("1"))
- val joinRoomJSON = gson.toJson(joinRoom)
+ val joinRoomJSON = gson.toJson(JoinRoom())
Log.d("request",joinRoomJSON)
- conection2.webSocketSingle?.send(joinRoomJSON)
+ conection.webSocketSingle?.send(joinRoomJSON)
btnCreaMesa.setOnClickListener {
Log.d("request", "mesnaje a enviar:{\"command\":\"create_room_table\",\"data\":{\"roomId\":\"1\",\"points\":30}} ")
- conection2.webSocketSingle?.send("{\"command\":\"create_room_table\",\"data\":{\"roomId\":\"1\",\"points\":30}}")
+ conection.webSocketSingle?.send(gson.toJson(CreateTable()))
}
}
+ fun iniciarRecyclerJugadores(){
+ jugadoresAdapter = JugadoresAdapter(listaJugadores)
+ lista_jugadores.apply {
+ layoutManager = LinearLayoutManager(this@MesasActivity)
+ adapter = jugadoresAdapter
+ }
+ }
+ fun iniciarRecyclerMesas(){
+ mesasAdapter = MesaAdapter(listaMesas){ cadena, join ->
+ Toast.makeText(this@MesasActivity, cadena, Toast.LENGTH_LONG).show()
+ val intentJuego = Intent(this@MesasActivity, MesaEnJuego::class.java)
+ intentJuego.putExtra("join", gson.toJson(join))
+ startActivity(intentJuego)
+ }
+ lista_mesas.apply {
+ layoutManager = LinearLayoutManager(this@MesasActivity)
+ adapter = mesasAdapter
+ }
+ }
+ fun agregarTableGetInit(entrada : EventGetRoom){
+ for (indiceT in entrada.data?.rooms?.get(0)?.tables?.indices!!) {
+ listaTables.add(ModelForTables(id = entrada.data.rooms[0].tables?.get(indiceT)?.id, state = entrada.data.rooms[0].tables?.get(indiceT)?.status, users = entrada.data.rooms[0].tables?.get(indiceT)?.positions))
+ }
+
+ }
+ fun agregarTable(entrada : EventCreateMesa){
+
+ listaTables.add(ModelForTables(id = entrada.data?.table?.id, state = entrada.data?.table?.status, users = entrada.data?.table?.users as List))
+ }
+ fun buscarDuplicados(){
+ /*if(list.removeAll { it == item }) {
+ println("Lista modificada: ${list}")
+ } else {
+ println("El elemento no existe!!")
+ } */
+ if (tamanioMesas > 1) {
+ for (indice in listaMesas.indices) {
+ if (listaMesas.removeAll { it == listaMesas[indice] }) {
+ tamanioMesas = listaMesas.size
+ mesasAdapter.notifyItemRemoved(tamanioMesas)
+ }
+ }
+ }
+ }
+ fun contieneId(lista: ArrayList, idNuevo : String?):Boolean{
+ var contiene = false
+ for (indice in lista.indices){
+ contiene = lista[indice].data?.table?.id != idNuevo
+ }
+ return contiene
+ }
+ fun adaptarEvento(evento : EventCreateMesa) : EventCreateMesa{
+ var resultado = EventCreateMesa()
+ resultado.command = evento.command
+ resultado.type = evento.type
+ resultado.data?.user = evento.data?.user
+ resultado.data?.room = evento.data?.room
+ resultado.data?.eventName = evento.data?.eventName
+ resultado.data?.table?.id = evento.data?.table?.id
+ resultado.data?.table?.owner = evento.data?.table?.owner
+ resultado.data?.table?.points = evento.data?.table?.points
+ resultado.data?.table?.privateTable = evento.data?.table?.privateTable
+ resultado.data?.table?.roomID = evento.data?.table?.roomID
+ resultado.data?.table?.status = evento.data?.table?.status
+ resultado.data?.table?.users?.add(evento.data?.table?.users!!.first())
+ return resultado
+ }
inner class TestListener : WebSocketListener() {
override fun onOpen(webSocket: WebSocket, response: Response) {
//Log.d("request", "connection successfully")
@@ -58,42 +136,92 @@ class MesasActivity : AppCompatActivity() {
override fun onMessage(webSocket: WebSocket, text: String) {
//usernameReceived.text = "cargando Rooms"
runOnUiThread {
- Log.d("request", "testRecibe : $text")
- //--------eventoRecibido = decoJson.fromJson(text, Events::class.java)
- Log.d("request", "evento Jugadores a EventsClass: $eventoRecibido")
- //------if (eventoRecibido.type == "TRUCO_ROOM_EVENT") {
- if (text.contains("TRUCO_ROOM_EVENT", true)) {
- eventoRecibido = decoJson.fromJson(text, Events::class.java)
- Log.d("request", "ENTRO AL ADAPTER!!!")
- val jugadores:ArrayList = eventoRecibido.data?.room?.users as ArrayList
- Log.d("request", "JUGADORES TIENE ESTO $jugadores")
- adapterJugadores = JugadoresAdapter(jugadores)
- lista_jugadores.apply {
- layoutManager = LinearLayoutManager(this@MesasActivity)
- adapter = adapterJugadores
+ if (text.contains(KeysWebSocket.commandResponse,true) && text.contains(KeysWebSocket.commandGetRooms)){
+ Log.d("TAG", "GETROOMS -> $text")
+ agregarTableGetInit(gson.fromJson(text, EventGetRoom::class.java))
+ Log.d("TAG", "ListaTables Nueva -> $listaTables")
+ /**********************************************Parte para el Recycler de Jugadores**************************************/
+ }else if (text.contains(KeysWebSocket.commandResponse,true) && text.contains(KeysWebSocket.commandJoinRoom)){
+ val eventJoinRoom = gson.fromJson(text, EventJoinRoom::class.java)
+ listaJugadores = eventJoinRoom.data?.room?.users!! as ArrayList
+ tamanioJugadores = listaJugadores.size
+ iniciarRecyclerJugadores()
+ }else if(text.contains(KeysWebSocket.trucoRoomEvent,true) && text.contains(KeysWebSocket.roomUserJoined)){
+ if (yaEntro) {
+ val eventTrucoRoom = gson.fromJson(text, EventJoinRoomTRE::class.java)
+ listaJugadores.add(UserElementJoin(user = UserUserJoin(eventTrucoRoom.data?.user!!.id, eventTrucoRoom.data.user.username ), online = true))
+ jugadoresAdapter.notifyItemInserted(tamanioJugadores)
+ }else yaEntro = true
+ }else if(text.contains(KeysWebSocket.trucoRoomEvent, true) && text.contains(KeysWebSocket.roomLeftRoom, true)){
+ val eventLeftTrucoRoom = gson.fromJson(text, EventJoinRoomTRE::class.java)
+ listaJugadores.remove(UserElementJoin(user = UserUserJoin(eventLeftTrucoRoom.data?.user!!.id, eventLeftTrucoRoom.data.user.username ), online = true))
+ jugadoresAdapter.notifyItemRemoved(tamanioJugadores)
+ /************************************************Parte para el Recycler de Mesas ****************************************************/
+ }else if (text.contains(KeysWebSocket.commandResponse,true) && text.contains(KeysWebSocket.commandCreateRoomTable)){
+ val eventoCreateTable = gson.fromJson(text, EventCreateMesa::class.java)
+ listaMesas.add(eventoCreateTable)
+ tamanioMesas = listaMesas.size
+ if (yaEntroMesaCreada){
+ mesasAdapter.notifyItemInserted(tamanioMesas)
+ }else {
+ iniciarRecyclerMesas()
+ buscarDuplicados()
+ yaEntroMesaCreada = true
+ }
+ }else if(text.contains(KeysWebSocket.trucoRoomEvent,true) && text.contains(KeysWebSocket.roomTableCreated,true)){
+ val eventoCreateTable = gson.fromJson(text, EventCreateMesa::class.java)
+ // Users solo tiene el owner size = 1
+ Log.d("TAG", "MesaCreada-> $eventoCreateTable")
+ if (listaMesas.isEmpty()){
+ listaMesas.add(eventoCreateTable)
+ tamanioMesas = listaMesas.size
+ iniciarRecyclerMesas()
+ }else{
+
+ if (contieneId(listaMesas, eventoCreateTable.data?.table?.id))
+ listaMesas.add(eventoCreateTable)
+ tamanioMesas = listaMesas.size
+ mesasAdapter.notifyItemInserted(tamanioMesas)
+ }
+ }else if(text.contains(KeysWebSocket.trucoRoomEvent, true) && text.contains(KeysWebSocket.roomTableUserJoined, true)){
+ var eventoJoined = gson.fromJson(text, EventCreateMesa::class.java)
+ var eventoJoinedAdaptado = adaptarEvento(eventoJoined)
+ for (indice in listaMesas.indices) {
+ if (listaMesas[indice].data?.table?.id == eventoJoinedAdaptado.data?.table?.id ) {
+ listaMesas[indice].data?.table?.users?.get(0)?.id = eventoJoinedAdaptado.data?.user?.id
+ listaMesas[indice].data?.table?.users?.get(0)?.username = eventoJoinedAdaptado.data?.user?.username
+ mesasAdapter.notifyItemChanged(indice)
+ }
+ }
+ }else if(text.contains(KeysWebSocket.trucoTableEvent,true)&&text.contains(KeysWebSocket.tablePositionSetted,true)){
+ var eventoJoined = gson.fromJson(text, EventTablePositionSetted::class.java)
+ Log.d("TAG", "se Unio $eventoJoined")
+ Log.d("TAG", "tamanio de la mesa hecha: ${listaMesas.first().data?.table?.users?.size}")
+ Log.d("TAG", "tamanio de la mesa recibida: ${eventoJoined.data?.table?.positions?.size}")
+ for (indice in listaMesas.indices) {
+ if (listaMesas[indice].data?.table?.id == eventoJoined.data?.table?.id ) {
+ Log.d("TAG", "entra para agregar Player!!!")
+ listaMesas[indice].data?.table?.users = eventoJoined.data?.table?.positions as ArrayList
+ //listaMesas[indice].data?.table?.users?.get(eventoJoined.data?.position!!.toInt())?.username = "X"
+ mesasAdapter.notifyItemChanged(tamanioMesas)
+ }
}
- //disparaAdapter()
}else{
- Log.d("request", "MENSAJE: $text")
+ Log.d("TAG", "Unidentified-> $text")
}
}
}
- override fun onMessage(webSocket: WebSocket, bytes: ByteString) {
- super.onMessage(webSocket, bytes)
- Log.d("request", "testRecibe : $bytes")
- }
override fun onClosing(webSocket: WebSocket, code: Int, reason: String) {
Log.d("request","testCierra : $code / $reason")
}
override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) {
Log.d("request","Error : " + t.message +response.toString())
- LobbyActivity.Conection.conectarconWS()
- val joinRoom = JoinData("join_room", Data("1"))
- val joinRoomJSON = gson.toJson(joinRoom)
+ conection.conectarconWS()
+ val joinRoomJSON = gson.toJson(JoinRoom())
Log.d("request",joinRoomJSON)
- LobbyActivity.Conection.webSocketSingle?.send(joinRoomJSON)
+ conection.webSocketSingle?.send(joinRoomJSON)
}
}
}
diff --git a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/Socket.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/Socket.kt
new file mode 100644
index 0000000..d4acb7f
--- /dev/null
+++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/Socket.kt
@@ -0,0 +1,28 @@
+package com.example.tolucagraphics
+
+import okhttp3.OkHttpClient
+import okhttp3.Request
+import okhttp3.WebSocket
+import okhttp3.WebSocketListener
+import java.util.concurrent.TimeUnit
+
+object Socket {
+
+ var username: String?= null
+ var SERVER_PATH: String?= null
+ private val client = OkHttpClient.Builder()
+ .readTimeout(1, TimeUnit.SECONDS)
+ .build()
+
+ var request : Request?=null
+ lateinit var listener : WebSocketListener
+ fun realizarConex() {
+ request = Request.Builder()
+ .url(SERVER_PATH + username)
+ .build()
+ }
+ var webSocketSingle : WebSocket?=null
+ fun conectarconWS(){
+ webSocketSingle = client.newWebSocket(request!!, listener)
+ }
+}
\ No newline at end of file
diff --git a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/JugadoresAdapter.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/JugadoresAdapter.kt
index 2c067a0..a21460a 100644
--- a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/JugadoresAdapter.kt
+++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/JugadoresAdapter.kt
@@ -7,8 +7,9 @@ import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.tolucagraphics.R
import com.example.tolucagraphics.events.UserElement
+import com.example.tolucagraphics.events.UserElementJoin
-class JugadoresAdapter (val listaJugadores : ArrayList) : RecyclerView.Adapter() {
+class JugadoresAdapter (val listaJugadores : ArrayList) : RecyclerView.Adapter() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MesaHolder {
var layoutInflate = LayoutInflater.from(parent.context)
@@ -21,7 +22,7 @@ class JugadoresAdapter (val listaJugadores : ArrayList) : Recycler
}
override fun onBindViewHolder(holder: MesaHolder, position: Int) {
- listaJugadores[position]?.let { holder.binder(it) }
+ holder.binder(listaJugadores[position])
}
class MesaHolder(view: View) : RecyclerView.ViewHolder(view) {
@@ -29,7 +30,7 @@ class JugadoresAdapter (val listaJugadores : ArrayList) : Recycler
private val rank: TextView = view.findViewById(R.id.campoRanking)
- fun binder(element : UserElement) {
+ fun binder(element : UserElementJoin) {
name.text = element.user?.id.toString()
rank.text = element.user?.username.toString()
diff --git a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/MesaAdapter.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/MesaAdapter.kt
new file mode 100644
index 0000000..02cedf9
--- /dev/null
+++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/MesaAdapter.kt
@@ -0,0 +1,67 @@
+package com.example.tolucagraphics.adapters
+
+import android.util.Log
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.Button
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.example.tolucagraphics.R
+import com.example.tolucagraphics.datas.DataJT
+import com.example.tolucagraphics.datas.JoinTable
+import com.example.tolucagraphics.events.EventCreateMesa
+
+class MesaAdapter(val mesasCreadas: ArrayList, var callback: (String, JoinTable) -> Unit) : RecyclerView.Adapter() {
+ override fun onCreateViewHolder(
+ parent: ViewGroup,
+ viewType: Int
+ ): JugadoresHolder {
+ val view = LayoutInflater.from(parent.context)
+ .inflate(R.layout.modelo_recycler_mesas, parent, false)
+ return JugadoresHolder(view)
+ }
+
+ override fun getItemCount(): Int {
+ return mesasCreadas.size
+ }
+
+ override fun onBindViewHolder(holder: JugadoresHolder, position: Int) {
+ holder.binding(mesasCreadas[position])
+ holder.itemView.findViewById