Skip to content

Commit

Permalink
fix: downgrade evalex and other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
agronick committed Dec 27, 2023
1 parent e2cdc31 commit aff1965
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
16 changes: 5 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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'
}

Expand Down Expand Up @@ -118,16 +112,16 @@ 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"
implementation 'com.google.protobuf:protobuf-javalite:3.25.1'
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'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/aatorque/stats/DashboardFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 5 additions & 6 deletions app/src/main/java/com/aatorque/stats/TorqueData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 -> {
Expand Down
14 changes: 10 additions & 4 deletions app/src/main/java/com/aatorque/stats/TorqueRefresher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit aff1965

Please sign in to comment.