minor changes

This commit is contained in:
matthias
2024-04-10 20:56:14 +02:00
parent ab1a7f1a3b
commit 8dead6d667
4 changed files with 1921 additions and 47 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -42,7 +42,7 @@ import com.schoolapp.cleverclass.ui.theme.TextOnColouredButton
class MainActivity : ComponentActivity() { class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
readData() readData(applicationContext)
setContent { setContent {
CleverClassTheme { CleverClassTheme {
Surface(modifier = Modifier.fillMaxSize(), Surface(modifier = Modifier.fillMaxSize(),

View File

@@ -79,9 +79,3 @@ fun PSEContent(activity: ComponentActivity){
} }
} }
} }
fun main() {
readData()
println(elements[0].data0)
println(elements[0].data10)
}

View File

@@ -1,10 +1,20 @@
package com.schoolapp.cleverclass package com.schoolapp.cleverclass
import android.content.Context
import android.content.res.AssetManager
import android.content.res.Resources
import android.content.res.loader.ResourcesProvider
import android.net.Uri
import java.io.BufferedReader
import java.io.File import java.io.File
import java.io.FileDescriptor
import java.io.FileInputStream
import java.io.FileReader
import java.io.IOException import java.io.IOException
import java.util.Scanner import java.io.InputStreamReader
val elements = mutableListOf<PSEData>() val elements = mutableListOf<PSEData>()
var i = 0
class PSEData() { class PSEData() {
var data0: String = "" var data0: String = ""
@@ -60,45 +70,43 @@ class PSEData() {
} }
} }
fun main() { fun readData(context: Context) {
readData() val elementInput = mutableListOf<String>()
} val file = "elements_data.txt"
fun readData() { val assetManager = context.assets
val elementInput = mutableListOf("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "") val inputStream = assetManager.open(file)
val fileName = "app/src/main/assets/elements_data.txt" try {
var i = 0 BufferedReader(InputStreamReader(inputStream)).use { br ->
while (i < 1) { br.lines().forEach {
try { elementInput.add(it)
val sc = Scanner(File(fileName))
var j = 0
while (j < 1) {
elementInput[j] = sc.nextLine()
j++
} }
} catch (e: IOException) {
e.printStackTrace()
} }
val pseobject = PSEData(
string0 = elementInput[0],
string1 = elementInput[1],
string2 = elementInput[2],
string3 = elementInput[3],
string4 = elementInput[4],
string5 = elementInput[5],
string6 = elementInput[6],
string7 = elementInput[7],
string8 = elementInput[8],
string9 = elementInput[9],
string10 = elementInput[10],
string11 = elementInput[11],
string12 = elementInput[12],
string13 = elementInput[13],
string14 = elementInput[14],
string15 = elementInput[15]
)
elements.add(pseobject)
i++
} }
println(elements[0].data0) catch (e: IOException) {
println("hi") e.printStackTrace()
}
if (i < 118) {
while (i < 118) {
val pseobject = PSEData(
string0 = elementInput[(i * 16)],
string1 = elementInput[(i * 16) + 1],
string2 = elementInput[(i * 16) + 2],
string3 = elementInput[(i * 16) + 3],
string4 = elementInput[(i * 16) + 4],
string5 = elementInput[(i * 16) + 5],
string6 = elementInput[(i * 16) + 6],
string7 = elementInput[(i * 16) + 7],
string8 = elementInput[(i * 16) + 8],
string9 = elementInput[(i * 16) + 9],
string10 = elementInput[(i * 16) + 10],
string11 = elementInput[(i * 16) + 11],
string12 = elementInput[(i * 16) + 12],
string13 = elementInput[(i * 16) + 13],
string14 = elementInput[(i * 16) + 14],
string15 = elementInput[(i * 16) + 15]
)
elements.add(pseobject)
i++
}
}
} }