From fefae1ebfb0c560c27da6dff24b961a706d40dc2 Mon Sep 17 00:00:00 2001 From: "jeremy.ducourthial" Date: Tue, 27 Feb 2024 19:22:07 +0100 Subject: [PATCH] =?UTF-8?q?feat=20:=20ajout=20cr=C3=A9ation=20d'un=20lobby?= =?UTF-8?q?=20en=20android?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Android/app/src/main/AndroidManifest.xml | 1 + .../example/mathseduc/CreateLobbyActivity.kt | 64 ++++++++++++++++ .../com/example/mathseduc/MultiActivity.kt | 9 ++- .../controllers/ControllerChapter.kt | 43 +++++++++++ .../mathseduc/controllers/ControllerLobby.kt | 39 +++++++++- .../com/example/mathseduc/models/Chapter.kt | 6 ++ .../com/example/mathseduc/models/Lobby.kt | 2 +- .../main/res/layout/activity_create_lobby.xml | 75 +++++++++++++++++++ Android/app/src/main/res/values/strings.xml | 14 ++++ 9 files changed, 250 insertions(+), 3 deletions(-) create mode 100644 Android/app/src/main/java/com/example/mathseduc/CreateLobbyActivity.kt create mode 100644 Android/app/src/main/java/com/example/mathseduc/controllers/ControllerChapter.kt create mode 100644 Android/app/src/main/java/com/example/mathseduc/models/Chapter.kt create mode 100644 Android/app/src/main/res/layout/activity_create_lobby.xml diff --git a/Android/app/src/main/AndroidManifest.xml b/Android/app/src/main/AndroidManifest.xml index 214188b..3f54b3e 100644 --- a/Android/app/src/main/AndroidManifest.xml +++ b/Android/app/src/main/AndroidManifest.xml @@ -21,5 +21,6 @@ + \ No newline at end of file diff --git a/Android/app/src/main/java/com/example/mathseduc/CreateLobbyActivity.kt b/Android/app/src/main/java/com/example/mathseduc/CreateLobbyActivity.kt new file mode 100644 index 0000000..267e16e --- /dev/null +++ b/Android/app/src/main/java/com/example/mathseduc/CreateLobbyActivity.kt @@ -0,0 +1,64 @@ +package com.example.mathseduc + +import android.content.Intent +import android.os.Bundle +import android.widget.* +import androidx.appcompat.app.AppCompatActivity +import com.example.mathseduc.controllers.ControllerChapter +import com.example.mathseduc.controllers.ControllerLobby +import com.example.mathseduc.models.Lobby +import org.json.JSONObject + + +class CreateLobbyActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_create_lobby) + + var spinnerChapter = findViewById(R.id.spinnerChapter) + + // Fetch chapters from API + val chaptersFromApi = ControllerChapter.getChapters() + + // Populate Spinner with fetched chapters + if (chaptersFromApi != null) { + val chapterNames = chaptersFromApi.map { it.name }.toTypedArray() + + val adapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, chapterNames) + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) + spinnerChapter.adapter = adapter + } + + val buttonCreateLobby = findViewById