summaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/example/alcagotchi/RequestTest.kt
diff options
context:
space:
mode:
authorLeightonGinty <lxg184@student.bham.ac.uk>2024-11-16 21:31:03 +0000
committerLeightonGinty <lxg184@student.bham.ac.uk>2024-11-16 21:31:03 +0000
commit0c6833c3ac42a6d371129d74271902165104684f (patch)
tree52ee1e93f56492b9bf0a9cc800f3001264aad589 /app/src/main/java/com/example/alcagotchi/RequestTest.kt
parentce75f5c1f5b19540a7304bea35d58fb102cf0710 (diff)
Drinking + get and post
Diffstat (limited to 'app/src/main/java/com/example/alcagotchi/RequestTest.kt')
-rw-r--r--app/src/main/java/com/example/alcagotchi/RequestTest.kt64
1 files changed, 64 insertions, 0 deletions
diff --git a/app/src/main/java/com/example/alcagotchi/RequestTest.kt b/app/src/main/java/com/example/alcagotchi/RequestTest.kt
new file mode 100644
index 0000000..513bb69
--- /dev/null
+++ b/app/src/main/java/com/example/alcagotchi/RequestTest.kt
@@ -0,0 +1,64 @@
+package com.example.alcagotchi
+
+import android.os.Bundle
+import android.util.Log
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Surface
+import com.example.alcagotchi.ui.theme.AlcaGotchiTheme
+import java.lang.reflect.Modifier
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.material3.Button
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+
+@Composable
+fun GetAmiiboItems(modifier: Modifier) {
+ val amiiboList = remember { mutableStateOf<List<AmiiboItem>>(listOf()) }
+ Column {
+ Button(onClick = {
+ asyncGetHttpRequest(
+ endpoint = "https://www.amiiboapi.com/api/amiibo/",
+ onSuccess = {
+ amiiboList.value = it.response.amiibo
+ Log.d("SUCCESS", amiiboList.toString())
+ },
+ onError = {
+ Log.d("ERROR", it.message.toString())
+ }
+ )
+ })
+ {
+ Text(
+ text = "Get Amiibos"
+ )
+ }
+ }
+ Column(
+// modifier = Modifier.fillMaxSize(),
+// contentPadding = PaddingValues(16.dp)
+ ) {
+ Text(text = amiiboList.value.toString())
+ }
+}
+class RequestTest : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ AlcaGotchiTheme {
+ // A surface container using the 'background' color from the theme
+ Surface(
+ color = MaterialTheme.colorScheme.background
+ ) {
+ // Let's create a composable function named GetAmiiboItems
+ GetAmiiboItems(modifier = Modifier())
+ }
+ }
+ }
+ }
+} \ No newline at end of file