This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-kapt'
|
||||
id 'com.google.dagger.hilt.android'
|
||||
id 'kotlin-kapt'
|
||||
}
|
||||
|
||||
// Create a variable called keystorePropertiesFile, and initialize it to your
|
||||
|
||||
@@ -10,10 +10,8 @@ import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.os.LocaleListCompat
|
||||
import com.google.gson.Gson
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import me.zobrist.tichucounter.databinding.ActivityMainBinding
|
||||
import me.zobrist.tichucounter.domain.History
|
||||
import me.zobrist.tichucounter.domain.Round
|
||||
import me.zobrist.tichucounter.domain.Tichu
|
||||
import me.zobrist.tichucounter.domain.getAbsoluteDifference
|
||||
@@ -22,6 +20,7 @@ import me.zobrist.tichucounter.fragments.KeyboardViewModel
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private var currentRound: Round = Round(null, null)
|
||||
@@ -29,6 +28,8 @@ class MainActivity : AppCompatActivity() {
|
||||
private val keyboardViewModel: KeyboardViewModel by viewModels()
|
||||
private val historyListViewModel: HistoryListViewModel by viewModels()
|
||||
|
||||
@Inject lateinit var tichu: Tichu
|
||||
|
||||
|
||||
private var ignoreNextUpdate: Boolean = false
|
||||
private var systemLocale = Locale.getDefault()
|
||||
@@ -61,8 +62,6 @@ class MainActivity : AppCompatActivity() {
|
||||
)
|
||||
|
||||
keyboardViewModel.scoreA.observe(this) { value ->
|
||||
val tichu = Tichu()
|
||||
|
||||
val oldValue = currentRound.scoreA
|
||||
currentRound.scoreA = value
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
import javax.inject.Inject
|
||||
|
||||
class History {
|
||||
private var scores = ArrayList<Round>()
|
||||
|
||||
@Inject
|
||||
constructor()
|
||||
|
||||
fun getScoreA(): Int {
|
||||
var tempScore = 0
|
||||
scores.forEach {
|
||||
tempScore += it.scoreA!!
|
||||
}
|
||||
return tempScore
|
||||
}
|
||||
|
||||
fun getScoreB(): Int {
|
||||
var tempScore = 0
|
||||
scores.forEach {
|
||||
tempScore += it.scoreB!!
|
||||
}
|
||||
return tempScore
|
||||
}
|
||||
|
||||
fun getHistoryA(): String {
|
||||
var tempHistory = String()
|
||||
scores.forEach {
|
||||
tempHistory += it.scoreA.toString() + "\n"
|
||||
}
|
||||
return tempHistory
|
||||
}
|
||||
|
||||
fun getHistoryB(): String {
|
||||
var tempHistory = String()
|
||||
scores.forEach {
|
||||
tempHistory += it.scoreB.toString() + "\n"
|
||||
}
|
||||
return tempHistory
|
||||
}
|
||||
|
||||
fun logRound(round: Round) {
|
||||
scores.add(round)
|
||||
}
|
||||
|
||||
fun revertLastRound() {
|
||||
if (scores.isNotEmpty()) {
|
||||
scores.removeAt(scores.size - 1)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearAll() {
|
||||
scores.clear()
|
||||
}
|
||||
|
||||
fun isEmpty(): Boolean {
|
||||
return scores.isEmpty()
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
class Tichu {
|
||||
import javax.inject.Inject
|
||||
|
||||
class Tichu @Inject constructor() {
|
||||
|
||||
fun calculateOtherScore(score: Int?): Int? {
|
||||
if (score == null) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package me.zobrist.tichucounter.framework
|
||||
|
||||
import android.app.Application
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
|
||||
@HiltAndroidApp
|
||||
class TichuCounterApplication : Application()
|
||||
Reference in New Issue
Block a user