Finish NotenActivity and FachActivity
This commit is contained in:
@@ -61,12 +61,12 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
var SAWeight = 0
|
||||
var name = "Test"
|
||||
private var SAWeight = 0
|
||||
private var name = "Test"
|
||||
|
||||
var typesSelection = listOf("Test", "Ex", "Referat", "Mündlich", "Sonstiges")
|
||||
val gradesSelection = listOf(1, 2, 3, 4, 5, 6)
|
||||
val weightsSelection = listOf(0.5f, 1f, 1.5f, 2f)
|
||||
private var typesSelection = listOf("Test", "Ex", "Referat", "Mündlich", "Sonstiges")
|
||||
private val gradesSelection = listOf(1, 2, 3, 4, 5, 6)
|
||||
private val weightsSelection = listOf(0.5f, 1f, 1.5f, 2f)
|
||||
|
||||
class FachActivity : ComponentActivity() {
|
||||
companion object {
|
||||
@@ -139,9 +139,7 @@ fun GradeContent(activity: ComponentActivity, loadedGrades: List<GradeData>){
|
||||
|
||||
DisposableEffect(activity) {
|
||||
onDispose {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
saveGrades(activity, grades, name)
|
||||
}
|
||||
saveGradesStart(activity, grades)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,9 +154,8 @@ fun GradeContent(activity: ComponentActivity, loadedGrades: List<GradeData>){
|
||||
)},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
saveGrades(activity, grades, name)
|
||||
}
|
||||
typesSelection = listOf("Test", "Ex", "Referat", "Mündlich", "Sonstiges")
|
||||
saveGradesStart(activity, grades)
|
||||
activity.finish()
|
||||
}) {
|
||||
Icon(
|
||||
@@ -197,7 +194,7 @@ fun GradeContent(activity: ComponentActivity, loadedGrades: List<GradeData>){
|
||||
style = MaterialTheme.typography.headlineSmall)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Text(
|
||||
text = "Ø" + if(average.isNaN()) "0.0" else formatFloat(average),
|
||||
text = "Ø" + formatFloat(average),
|
||||
style = MaterialTheme.typography.headlineSmall)
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
}
|
||||
@@ -226,20 +223,25 @@ fun GradeContent(activity: ComponentActivity, loadedGrades: List<GradeData>){
|
||||
grades.forEach{ gradeData ->
|
||||
GradePrefab(
|
||||
id = gradeData.id,
|
||||
onClose = { grades = grades.filter { it.id != gradeData.id } },
|
||||
onClose = {
|
||||
grades = grades.filter { it.id != gradeData.id }
|
||||
saveGradesStart(activity, grades) },
|
||||
type = gradeData.type,
|
||||
grade = gradeData.grade,
|
||||
weight = gradeData.weight,
|
||||
color = gradeData.color,
|
||||
onGradeChange = { grade ->
|
||||
grades.find { it.id == gradeData.id }?.grade = grade
|
||||
average = calculateAverage(grades, editor) },
|
||||
average = calculateAverage(grades, editor)
|
||||
saveGradesStart(activity, grades) },
|
||||
onWeightChange = { weight ->
|
||||
grades.find { it.id == gradeData.id }?.weight = weight
|
||||
average = calculateAverage(grades, editor) },
|
||||
average = calculateAverage(grades, editor)
|
||||
saveGradesStart(activity, grades) },
|
||||
onTypeChange = { type ->
|
||||
grades.find { it.id == gradeData.id }?.type = type
|
||||
average = calculateAverage(grades, editor) }
|
||||
average = calculateAverage(grades, editor)
|
||||
saveGradesStart(activity, grades) }
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(216.dp))
|
||||
@@ -258,6 +260,7 @@ fun GradeContent(activity: ComponentActivity, loadedGrades: List<GradeData>){
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
modifier = Modifier.clickable {
|
||||
grades = emptyList()
|
||||
saveGradesStart(activity, grades)
|
||||
editor.putFloat(name, 0.0f).apply()
|
||||
showDeleteConfirmation = false
|
||||
}
|
||||
@@ -555,3 +558,9 @@ fun calculateAverage(grades: List<GradeData>, editor: Editor): Float {
|
||||
|
||||
return finalGrade
|
||||
}
|
||||
|
||||
fun saveGradesStart(context: Context, grades: List<GradeData>){
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
saveGrades(context, grades, name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user