cards #8
3 changed files with 27 additions and 13 deletions
|
@ -45,4 +45,3 @@ data class ValidationEntity (
|
|||
const val TABLE_NAME = "validations"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ fun CommunicationWifiP2pServerContent(
|
|||
bwfManager: BwfManager,
|
||||
client: MutableState<TaskClient?>
|
||||
) {
|
||||
/*
|
||||
val expandedStudentList = remember { mutableStateOf(false) }
|
||||
val serverPort = remember { mutableIntStateOf(DEFAULT_SERVER_PORT) }
|
||||
|
||||
|
@ -98,6 +99,7 @@ fun CommunicationWifiP2pServerContent(
|
|||
"admin",
|
||||
"123456789",
|
||||
"admin",
|
||||
|
||||
)
|
||||
|
||||
// Insert the admin in the database
|
||||
|
@ -115,4 +117,5 @@ fun CommunicationWifiP2pServerContent(
|
|||
Text("Create")
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -1,9 +1,16 @@
|
|||
package com.faraphel.tasks_valider.ui.screen.task
|
||||
|
||||
import android.app.Activity
|
||||
import android.widget.Toast
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import com.faraphel.tasks_valider.connectivity.task.TaskClient
|
||||
import com.faraphel.tasks_valider.connectivity.task.session.TaskSession
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
|
||||
|
||||
/**
|
||||
|
@ -15,6 +22,13 @@ import com.faraphel.tasks_valider.connectivity.task.TaskClient
|
|||
fun TaskSessionScreen(activity: Activity, client: TaskClient) {
|
||||
Text("WIP : Session Screen")
|
||||
|
||||
val session = remember { mutableStateOf<TaskSession?>(null) }
|
||||
|
||||
if (session.value == null)
|
||||
return Thread { refreshGroups(activity, client, session) }.start()
|
||||
|
||||
Text("Session: ${session.value!!}")
|
||||
|
||||
/*
|
||||
val students = remember { mutableStateOf<List<TaskGroupEntity>?>(null) }
|
||||
|
||||
|
@ -35,21 +49,19 @@ fun TaskSessionScreen(activity: Activity, client: TaskClient) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
fun refreshGroups(activity: Activity, client: TaskClient, groups: MutableState<List<TaskGroupEntity>?>) {
|
||||
fun refreshGroups(activity: Activity, client: TaskClient, session: MutableState<TaskSession?>) {
|
||||
val jsonParser = Gson()
|
||||
|
||||
// try to obtain the list of groups
|
||||
val response = client.get("entities/group")
|
||||
val response = client.get("sessions/self")
|
||||
|
||||
// in case of error, notify it
|
||||
if (!response.isSuccessful) {
|
||||
Toast.makeText(activity, response.message, Toast.LENGTH_LONG).show()
|
||||
return
|
||||
}
|
||||
if (!response.isSuccessful)
|
||||
return activity.runOnUiThread { Toast.makeText(activity, response.message, Toast.LENGTH_LONG).show() }
|
||||
|
||||
// parse the list of groups
|
||||
groups.value = jsonParser.fromJson(
|
||||
response.body.toString(),
|
||||
object : TypeToken<List<TaskGroupEntity>>(){}
|
||||
session.value = jsonParser.fromJson(
|
||||
response.body.string(),
|
||||
object : TypeToken<TaskSession>(){}.type
|
||||
)
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in a new issue