diff --git a/app/build.gradle b/app/build.gradle index 794de68c..c2f3b813 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,7 +33,7 @@ android { buildConfigField "boolean", "SIMULATE_METRICS", "false" resourceConfigurations += ['en', 'cs', 'de', 'el', 'es', 'fr', 'fr-rCA', 'it', 'nl', 'pl', 'pt', 'pt-rBR', 'ru', 'sl', 'uk'] } - applicationVariants.all { + applicationVariants.configureEach { buildConfigField "String", "RELEASE_URL", "\"https://api.github.com/repos/${ghOwner}/${ghPackage}/releases/latest\"" } buildTypes { @@ -72,15 +72,9 @@ android { kotlinOptions { jvmTarget = "19" } - packaging { - resources { - excludes += '/META-INF/{AL2.0,LGPL2.1}' - } - } - buildToolsVersion '34.0.0' } -configurations.all { +configurations.configureEach { exclude group: 'com.google.guava', module: 'guava-jdk5' } @@ -118,8 +112,8 @@ dependencies { implementation project(':speedviewlib') testImplementation 'junit:junit:4.13.2' - implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.21' - implementation 'com.ezylang:EvalEx:3.1.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation 'com.ezylang:EvalEx:3.0.5' implementation 'androidx.annotation:annotation:1.7.1' implementation "androidx.datastore:datastore:1.0.0" @@ -127,7 +121,7 @@ dependencies { implementation 'rongi.rotate-layout:rotate-layout:3.0.0' implementation 'androidx.databinding:databinding-runtime:8.2.0' // implementation 'com.google.dagger:hilt-android:2.48' - // kapt 'com.google.dagger:hilt-compiler:2.48' + // kapt 'com.google.dagger:hilt-compiler:2.48' implementation "ch.acra:acra-mail:$acraVersion" implementation "ch.acra:acra-toast:$acraVersion" implementation 'com.github.martin-stone:hsv-alpha-color-picker-android:3.1.0' diff --git a/app/src/main/java/com/aatorque/stats/DashboardFragment.kt b/app/src/main/java/com/aatorque/stats/DashboardFragment.kt index ccf554ab..d415ea4d 100644 --- a/app/src/main/java/com/aatorque/stats/DashboardFragment.kt +++ b/app/src/main/java/com/aatorque/stats/DashboardFragment.kt @@ -118,7 +118,7 @@ open class DashboardFragment : AlbumArt() { if (it.showChart) { torqueChart.setupItems( screens.gaugesList.mapIndexed { index, display -> - torqueRefresher.populateQuery(index, screenIndex, display) + torqueRefresher.updateIfNeeded(index, screenIndex, display) }.toTypedArray() ) } else { diff --git a/app/src/main/java/com/aatorque/stats/TorqueData.kt b/app/src/main/java/com/aatorque/stats/TorqueData.kt index 4f2a6c97..6ea19ae2 100644 --- a/app/src/main/java/com/aatorque/stats/TorqueData.kt +++ b/app/src/main/java/com/aatorque/stats/TorqueData.kt @@ -5,6 +5,7 @@ import android.icu.text.NumberFormat import com.aatorque.datastore.Display import com.ezylang.evalex.BaseException import com.ezylang.evalex.Expression +import com.ezylang.evalex.data.EvaluationValue import timber.log.Timber import java.util.concurrent.ScheduledFuture @@ -77,14 +78,12 @@ class TorqueData(var display: Display) { } return try { val result = expression!!.with("a", value).evaluate() - val asNumber = result.numberValue - val asString = try { - result.stringValue.toDouble() - numberFormatter.format(result.numberValue) - } catch (e: NumberFormatException) { + val asString = if (result.dataType == EvaluationValue.DataType.STRING) { result.stringValue + } else { + numberFormatter.format(result.numberValue) } - Pair(asNumber.toDouble(), asString) + Pair(result.numberValue.toDouble(), asString) } catch (ex: Exception) { when(ex) { is BaseException, is NoSuchElementException, is NumberFormatException -> { diff --git a/app/src/main/java/com/aatorque/stats/TorqueRefresher.kt b/app/src/main/java/com/aatorque/stats/TorqueRefresher.kt index 194fb704..6122f999 100644 --- a/app/src/main/java/com/aatorque/stats/TorqueRefresher.kt +++ b/app/src/main/java/com/aatorque/stats/TorqueRefresher.kt @@ -28,10 +28,8 @@ class TorqueRefresher { fun populateQuery(pos: Int, screen: Int, query: Display): TorqueData { data[pos]?.stopRefreshing(true) val cacheItem = cache[screen]?.get(pos) - val torqueData = if (cacheItem != null && cacheItem.display.pid == query.pid) { - cache[screen]!![pos]!!.also { - it.display = query - } + val torqueData = if (cacheItem?.display?.equals(query) == true) { + cacheItem } else { TorqueData(query) } @@ -102,6 +100,14 @@ class TorqueRefresher { return data[idx]?.display?.equals(otherScreen) != true } + fun updateIfNeeded(pos: Int, screen: Int, query: Display): TorqueData { + return if (hasChanged(pos, query)) { + populateQuery(pos, screen, query) + } else { + data[pos]!! + } + } + fun watchConnection(service: TorqueService, notifyConState: ConStatusFn) { notifyConState(lastConnectStatus) service.addConnectCallback { diff --git a/build.gradle b/build.gradle index 964c5379..56047f70 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.9.10' + ext.kotlin_version = '1.9.21' ext.gradle_version = '8.1.4' ext.google_services_version = '4.3.15' repositories {