From e7d6546198de84b71c271f3a87283aa3989fd8f3 Mon Sep 17 00:00:00 2001 From: Miguel Do Carmo Date: Wed, 13 May 2020 21:55:19 -0300 Subject: [PATCH] no presionar el boton Crear Sala o cosas malas van a pasar xd --- TolucaGraphics - copia/.gitignore | 14 ++++++++++++++ TolucaGraphics - copia/.idea/codeStyles/Project.xml | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/.idea/codeStyles/codeStyleConfig.xml | 5 +++++ TolucaGraphics - copia/.idea/dictionaries/Miguel_Do_Carmo.xml | 11 +++++++++++ TolucaGraphics - copia/.idea/gradle.xml | 20 ++++++++++++++++++++ TolucaGraphics - copia/.idea/misc.xml | 9 +++++++++ TolucaGraphics - copia/.idea/runConfigurations.xml | 12 ++++++++++++ TolucaGraphics - copia/app/.gitignore | 1 + TolucaGraphics - copia/app/build.gradle | 42 ++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/proguard-rules.pro | 21 +++++++++++++++++++++ TolucaGraphics - copia/app/src/androidTest/java/com/example/tolucagraphics/ExampleInstrumentedTest.kt | 24 ++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/AndroidManifest.xml | 28 ++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/LobbyActivity.kt | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MainActivity.kt | 21 +++++++++++++++++++++ TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MesasActivity.kt | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/JugadoresAdapter.kt | 40 ++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/MesasAdapter.kt | 43 +++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/datas/Datas.kt | 29 +++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/events/Events.kt | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/res/drawable-v24/ic_launcher_foreground.xml | 30 ++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/res/drawable/button_style.xml | 10 ++++++++++ TolucaGraphics - copia/app/src/main/res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/res/font/cosiris_cure.ttf | Bin 0 -> 44704 bytes TolucaGraphics - copia/app/src/main/res/layout/activity_lobby.xml | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/res/layout/activity_main.xml | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/res/layout/activity_mesas_players.xml | 273 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/res/layout/modelo_jugadores.xml | 41 +++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/res/layout/modelo_recycler_mesas.xml | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml | 5 +++++ TolucaGraphics - copia/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml | 5 +++++ TolucaGraphics - copia/app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3593 bytes TolucaGraphics - copia/app/src/main/res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5339 bytes TolucaGraphics - copia/app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2636 bytes TolucaGraphics - copia/app/src/main/res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 3388 bytes TolucaGraphics - copia/app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4926 bytes TolucaGraphics - copia/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7472 bytes TolucaGraphics - copia/app/src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7909 bytes TolucaGraphics - copia/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 11873 bytes TolucaGraphics - copia/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 10652 bytes TolucaGraphics - copia/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 16570 bytes TolucaGraphics - copia/app/src/main/res/values/colors.xml | 11 +++++++++++ TolucaGraphics - copia/app/src/main/res/values/dimen.xml | 6 ++++++ TolucaGraphics - copia/app/src/main/res/values/strings.xml | 9 +++++++++ TolucaGraphics - copia/app/src/main/res/values/styles.xml | 11 +++++++++++ TolucaGraphics - copia/app/src/test/java/com/example/tolucagraphics/ExampleUnitTest.kt | 17 +++++++++++++++++ TolucaGraphics - copia/build.gradle | 29 +++++++++++++++++++++++++++++ TolucaGraphics - copia/gradle.properties | 21 +++++++++++++++++++++ TolucaGraphics - copia/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes TolucaGraphics - copia/gradle/wrapper/gradle-wrapper.properties | 6 ++++++ TolucaGraphics - copia/gradlew | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/gradlew.bat | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TolucaGraphics - copia/settings.gradle | 2 ++ 52 files changed, 1889 insertions(+) create mode 100644 TolucaGraphics - copia/.gitignore create mode 100644 TolucaGraphics - copia/.idea/codeStyles/Project.xml create mode 100644 TolucaGraphics - copia/.idea/codeStyles/codeStyleConfig.xml create mode 100644 TolucaGraphics - copia/.idea/dictionaries/Miguel_Do_Carmo.xml create mode 100644 TolucaGraphics - copia/.idea/gradle.xml create mode 100644 TolucaGraphics - copia/.idea/misc.xml create mode 100644 TolucaGraphics - copia/.idea/runConfigurations.xml create mode 100644 TolucaGraphics - copia/app/.gitignore create mode 100644 TolucaGraphics - copia/app/build.gradle create mode 100644 TolucaGraphics - copia/app/proguard-rules.pro create mode 100644 TolucaGraphics - copia/app/src/androidTest/java/com/example/tolucagraphics/ExampleInstrumentedTest.kt create mode 100644 TolucaGraphics - copia/app/src/main/AndroidManifest.xml create mode 100644 TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/LobbyActivity.kt create mode 100644 TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MainActivity.kt create mode 100644 TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MesasActivity.kt create mode 100644 TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/JugadoresAdapter.kt create mode 100644 TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/MesasAdapter.kt create mode 100644 TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/datas/Datas.kt create mode 100644 TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/events/Events.kt create mode 100644 TolucaGraphics - copia/app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/drawable/button_style.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/font/cosiris_cure.ttf create mode 100644 TolucaGraphics - copia/app/src/main/res/layout/activity_lobby.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/layout/activity_main.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/layout/activity_mesas_players.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/layout/modelo_jugadores.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/layout/modelo_recycler_mesas.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 TolucaGraphics - copia/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 TolucaGraphics - copia/app/src/main/res/values/colors.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/values/dimen.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/values/strings.xml create mode 100644 TolucaGraphics - copia/app/src/main/res/values/styles.xml create mode 100644 TolucaGraphics - copia/app/src/test/java/com/example/tolucagraphics/ExampleUnitTest.kt create mode 100644 TolucaGraphics - copia/build.gradle create mode 100644 TolucaGraphics - copia/gradle.properties create mode 100644 TolucaGraphics - copia/gradle/wrapper/gradle-wrapper.jar create mode 100644 TolucaGraphics - copia/gradle/wrapper/gradle-wrapper.properties create mode 100644 TolucaGraphics - copia/gradlew create mode 100644 TolucaGraphics - copia/gradlew.bat create mode 100644 TolucaGraphics - copia/settings.gradle diff --git a/TolucaGraphics - copia/.gitignore b/TolucaGraphics - copia/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/TolucaGraphics - copia/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/TolucaGraphics - copia/.idea/codeStyles/Project.xml b/TolucaGraphics - copia/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..88ea3aa --- /dev/null +++ b/TolucaGraphics - copia/.idea/codeStyles/Project.xml @@ -0,0 +1,122 @@ + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/TolucaGraphics - copia/.idea/codeStyles/codeStyleConfig.xml b/TolucaGraphics - copia/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/TolucaGraphics - copia/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/TolucaGraphics - copia/.idea/dictionaries/Miguel_Do_Carmo.xml b/TolucaGraphics - copia/.idea/dictionaries/Miguel_Do_Carmo.xml new file mode 100644 index 0000000..b70bcca --- /dev/null +++ b/TolucaGraphics - copia/.idea/dictionaries/Miguel_Do_Carmo.xml @@ -0,0 +1,11 @@ + + + + campo + campotest + droom + evento + jugadores + + + \ No newline at end of file diff --git a/TolucaGraphics - copia/.idea/gradle.xml b/TolucaGraphics - copia/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/TolucaGraphics - copia/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/TolucaGraphics - copia/.idea/misc.xml b/TolucaGraphics - copia/.idea/misc.xml new file mode 100644 index 0000000..37a7509 --- /dev/null +++ b/TolucaGraphics - copia/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/TolucaGraphics - copia/.idea/runConfigurations.xml b/TolucaGraphics - copia/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/TolucaGraphics - copia/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/TolucaGraphics - copia/app/.gitignore b/TolucaGraphics - copia/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/TolucaGraphics - copia/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/TolucaGraphics - copia/app/build.gradle b/TolucaGraphics - copia/app/build.gradle new file mode 100644 index 0000000..9d2cabc --- /dev/null +++ b/TolucaGraphics - copia/app/build.gradle @@ -0,0 +1,42 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 29 + buildToolsVersion "29.0.3" + + defaultConfig { + applicationId "com.example.tolucagraphics" + minSdkVersion 16 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.core:core-ktx:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + + implementation 'androidx.recyclerview:recyclerview:1.1.0' + implementation 'com.squareup.okhttp3:okhttp:4.4.0' + implementation 'com.google.code.gson:gson:2.8.6' + +} diff --git a/TolucaGraphics - copia/app/proguard-rules.pro b/TolucaGraphics - copia/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/TolucaGraphics - copia/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/TolucaGraphics - copia/app/src/androidTest/java/com/example/tolucagraphics/ExampleInstrumentedTest.kt b/TolucaGraphics - copia/app/src/androidTest/java/com/example/tolucagraphics/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..f388d83 --- /dev/null +++ b/TolucaGraphics - copia/app/src/androidTest/java/com/example/tolucagraphics/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.tolucagraphics + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.example.tolucagraphics", appContext.packageName) + } +} diff --git a/TolucaGraphics - copia/app/src/main/AndroidManifest.xml b/TolucaGraphics - copia/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c1b17b4 --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 0000000..419822f --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/LobbyActivity.kt @@ -0,0 +1,115 @@ +package com.example.tolucagraphics + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.Bundle +import android.util.Log +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.google.gson.Gson +import kotlinx.android.synthetic.main.activity_lobby.* +import okhttp3.* +import java.util.concurrent.TimeUnit + +class LobbyActivity : AppCompatActivity(){ + + val conection = Conection + 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 + + @SuppressLint("SetTextI18n") + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_lobby) + username = intent.getStringExtra("USERNAME") + + initiateSocketConnection() // inicia conexion con websocket\ + + /*********peticion de ROOMS**********/ + val getRooms = GetRooms("get_rooms") + val getRoomsJSON = gson.toJson(getRooms) + Log.d("request",getRoomsJSON) + //webSocket.send(getRoomsJSON) + //webSocket.close(1000, "finish") + conection.webSocketSingle?.send(getRoomsJSON) + + + btnSelect.setOnClickListener { + actualizarView() + val segundaPantalla = Intent(this, MesasActivity::class.java) + startActivity(segundaPantalla) + } + //////////////////////webSocket.close(1000, "Finish") + } + + private fun actualizarView() { + lobbyRooms.visibility = View.INVISIBLE + } + + private fun initiateSocketConnection() { + ////////////////////////// + conection.SERVER_PATH = SERVER_PATH + conection.username = username + conection.realizarConex() + /*val wsListener = WSListener () + webSocket = conection.client.newWebSocket(conection.request!!, wsListener) // realiza la conexion webSocket*/ + conection.listener = WSListener() + conection.conectarconWS() + } + + inner class WSListener : WebSocketListener() { + override fun onOpen(webSocket: WebSocket, response: Response) { + //Log.d("request", "connection successfully") + Log.d("request","Conection Success desde onOpen") + //webSocket.close(1000, "finish") + } + @SuppressLint("SetTextI18n") + override fun onMessage(webSocket: WebSocket, text: String) { + //usernameReceived.text = "cargando Rooms" + Log.d("request", "Receiving : $text") + val gsonreceived = Gson() + runOnUiThread { + eventReceived = gsonreceived.fromJson(text, Events::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 ?: "-" + } + } + } + override fun onClosing(webSocket: WebSocket, code: Int, reason: String) { + Log.d("request","Closing : $code / $reason") + } + override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) { + 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/MainActivity.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MainActivity.kt new file mode 100644 index 0000000..7730ef0 --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MainActivity.kt @@ -0,0 +1,21 @@ +package com.example.tolucagraphics + +import android.content.Intent +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import kotlinx.android.synthetic.main.activity_main.* + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + btnIngresar.setOnClickListener { + val intent = Intent(this, LobbyActivity::class.java) + intent.putExtra("USERNAME", usernameInput.text.toString()) + startActivity(intent) + } + + } + +} 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 new file mode 100644 index 0000000..b1d908d --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/MesasActivity.kt @@ -0,0 +1,99 @@ +package com.example.tolucagraphics + +import android.annotation.SuppressLint +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.util.Log +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.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 + + 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() + + /********************PETICION DE MESAS******************/ + val joinRoom = JoinData("join_room", Data("1")) + val joinRoomJSON = gson.toJson(joinRoom) + Log.d("request",joinRoomJSON) + conection2.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}}") + + } + + } + inner class TestListener : WebSocketListener() { + override fun onOpen(webSocket: WebSocket, response: Response) { + //Log.d("request", "connection successfully") + Log.d("request","vuelto a abrir???") + //webSocket.close(1000, "finish") + } + @SuppressLint("SetTextI18n") + 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 + } + //disparaAdapter() + }else{ + Log.d("request", "MENSAJE: $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) + Log.d("request",joinRoomJSON) + LobbyActivity.Conection.webSocketSingle?.send(joinRoomJSON) + } + } +} 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 new file mode 100644 index 0000000..2c067a0 --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/JugadoresAdapter.kt @@ -0,0 +1,40 @@ +package com.example.tolucagraphics.adapters + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.example.tolucagraphics.R +import com.example.tolucagraphics.events.UserElement + +class JugadoresAdapter (val listaJugadores : ArrayList) : RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MesaHolder { + var layoutInflate = LayoutInflater.from(parent.context) + .inflate(R.layout.modelo_jugadores, parent, false) + return MesaHolder(layoutInflate) + } + + override fun getItemCount(): Int { + return listaJugadores.size + } + + override fun onBindViewHolder(holder: MesaHolder, position: Int) { + listaJugadores[position]?.let { holder.binder(it) } + } + + class MesaHolder(view: View) : RecyclerView.ViewHolder(view) { + private val name: TextView = view.findViewById(R.id.campoNomgreJugadores) + private val rank: TextView = view.findViewById(R.id.campoRanking) + + + fun binder(element : UserElement) { + 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/MesasAdapter.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/MesasAdapter.kt new file mode 100644 index 0000000..52bf9db --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/adapters/MesasAdapter.kt @@ -0,0 +1,43 @@ +package com.example.tolucagraphics.adapters + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.example.tolucagraphics.R +import com.example.tolucagraphics.events.UserElement + +class MesasAdapter (val listamesa : ArrayList) : RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MesaHolder { + var layoutInflate = LayoutInflater.from(parent.context) + .inflate(R.layout.modelo_recycler_mesas, parent, false) + return MesaHolder(layoutInflate) + } + + override fun getItemCount(): Int { + return listamesa.size + } + + override fun onBindViewHolder(holder: MesaHolder, position: Int) { + holder.vindeando(listamesa[position]) + } + + class MesaHolder(view: View) : RecyclerView.ViewHolder(view) { + val id = view.findViewById(R.id.campoMesaId) + val st = view.findViewById(R.id.campoMesaEstado) + val s1 = view.findViewById(R.id.campoMesaS1) + val s2 = view.findViewById(R.id.campoMesaS2) + val s3 = view.findViewById(R.id.campoMesaS3) + val s4 = view.findViewById(R.id.campoMesaS4) + val s5 = view.findViewById(R.id.campoMesaS5) + val s6 = view.findViewById(R.id.campoMesaS6) + + + fun vindeando(elemento : UserElement) { + } + + } +} + diff --git a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/datas/Datas.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/datas/Datas.kt new file mode 100644 index 0000000..34d4ea7 --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/datas/Datas.kt @@ -0,0 +1,29 @@ +package com.example.tolucagraphics.datas + +data class UsernameData ( + val username: String? = null, + val id: String? = null +) + +data class Data ( + val roomId: String? = null, + val points: String? = null +) + +data class GetRooms( + val command: String? =null +) + +data class JoinData ( + val command: String? = null, + val data: Data? = null +) +data class JoinTable ( + val command: String? = null, + val data: Data? = null +) + +data class ModeloJugadores( + val jugadorNombre: String?= null, + val jugadorRanking: String?= null +) \ No newline at end of file diff --git a/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/events/Events.kt b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/events/Events.kt new file mode 100644 index 0000000..7067a4e --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/java/com/example/tolucagraphics/events/Events.kt @@ -0,0 +1,55 @@ +package com.example.tolucagraphics.events + +data class Events ( + val type: String? = null, + val command: String? = null, + val data: Data? = null +) + +data class Data ( + val eventName: String? = null, + val user: UserUser? = null, + val message: String? = null, + val room: Room? = null, + val rooms: Array? = null +) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Data + + if (eventName != other.eventName) return false + if (user != other.user) return false + if (rooms != null) { + if (other.rooms == null) return false + if (!rooms.contentEquals(other.rooms)) return false + } else if (other.rooms != null) return false + + return true + } + + override fun hashCode(): Int { + var result = eventName?.hashCode() ?: 0 + result = 31 * result + (user?.hashCode() ?: 0) + result = 31 * result + (rooms?.contentHashCode() ?: 0) + return result + } +} + +data class Room ( + val id: String? = null, + val name: String? = null, + val users: List? = null, + val tables: List? = null +) + +data class UserElement ( + val user: UserUser? = null, + val online: Boolean? = null +) + +data class UserUser ( + val id: String? = null, + val username: String? = null +) \ No newline at end of file diff --git a/TolucaGraphics - copia/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/TolucaGraphics - copia/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/TolucaGraphics - copia/app/src/main/res/drawable/button_style.xml b/TolucaGraphics - copia/app/src/main/res/drawable/button_style.xml new file mode 100644 index 0000000..537821e --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/res/drawable/button_style.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/TolucaGraphics - copia/app/src/main/res/drawable/ic_launcher_background.xml b/TolucaGraphics - copia/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TolucaGraphics - copia/app/src/main/res/font/cosiris_cure.ttf b/TolucaGraphics - copia/app/src/main/res/font/cosiris_cure.ttf new file mode 100644 index 0000000..3d483a2 Binary files /dev/null and b/TolucaGraphics - copia/app/src/main/res/font/cosiris_cure.ttf differ diff --git a/TolucaGraphics - copia/app/src/main/res/layout/activity_lobby.xml b/TolucaGraphics - copia/app/src/main/res/layout/activity_lobby.xml new file mode 100644 index 0000000..b2ddb0e --- /dev/null +++ b/TolucaGraphics - copia/app/src/main/res/layout/activity_lobby.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + +