fix: crash because of network running main on main thread and update deps
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
}
|
||||
|
||||
@@ -33,9 +32,6 @@ android {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
@@ -51,6 +47,10 @@ dependencies {
|
||||
implementation(libs.androidx.compose.ui.tooling.preview)
|
||||
implementation(libs.androidx.compose.material3)
|
||||
implementation(libs.androidx.compose.material3.adaptive.navigation.suite)
|
||||
implementation(libs.androidx.material3)
|
||||
implementation(libs.androidx.compose.material3.window.size.class1)
|
||||
implementation(libs.androidx.material.icons.core)
|
||||
implementation(libs.androidx.material.icons.extended)
|
||||
implementation(libs.okhttp)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
@@ -14,7 +16,6 @@
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.SoftwareManager">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.KeksPirates.SoftwareManager
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.StrictMode
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
@@ -24,14 +25,11 @@ import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewScreenSizes
|
||||
import com.KeksPirates.SoftwareManager.ui.theme.SoftwareManagerTheme
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import java.io.IOException
|
||||
|
||||
private val client = OkHttpClient()
|
||||
|
||||
fun run(): String {
|
||||
val request = Request.Builder()
|
||||
.url("https://publicobject.com/helloworld.txt")
|
||||
@@ -44,8 +42,8 @@ fun run(): String {
|
||||
println("$name: $value")
|
||||
}
|
||||
|
||||
println(response.body!!.string())
|
||||
response.body!!.string()
|
||||
// println(response.body.string())
|
||||
response.body.string()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +54,13 @@ class MainActivity : ComponentActivity() {
|
||||
setContent {
|
||||
SoftwareManagerTheme {
|
||||
SoftwareManagerApp()
|
||||
Thread {
|
||||
try {
|
||||
println(run())
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,7 +110,6 @@ enum class AppDestinations(
|
||||
fun Greeting(name: String, modifier: Modifier = Modifier) {
|
||||
Text(
|
||||
text = "Hello $name!",
|
||||
// text = run(),
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
@@ -114,9 +118,7 @@ fun Greeting(name: String, modifier: Modifier = Modifier) {
|
||||
@Composable
|
||||
fun GreetingPreview() {
|
||||
SoftwareManagerTheme {
|
||||
// Greeting("Android")
|
||||
// println(run())
|
||||
Greeting("test")
|
||||
Greeting("Android")
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user