Skip to content

Commit

Permalink
Tweaking responsiveness on reset and trip change
Browse files Browse the repository at this point in the history
  • Loading branch information
Ixam97 committed Apr 18, 2024
1 parent 94e96c5 commit 6e243b4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
4 changes: 2 additions & 2 deletions automotive/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
defaultConfig {
minSdkVersion 29
targetSdkVersion 34
versionCode 209
versionName "0.27.0.0004"
versionCode 211
versionName "0.27.0.0006"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.ixam97.carStatsViewer.carApp

import android.content.Intent
import android.os.Handler
import android.os.Looper
import androidx.car.app.CarContext
import androidx.car.app.Screen
import androidx.car.app.annotations.ExperimentalCarApi
Expand Down Expand Up @@ -66,7 +68,9 @@ class CarStatsViewerScreen(carContext: CarContext) : Screen(carContext) {
lifecycle.addObserver(object : DefaultLifecycleObserver {
override fun onResume(owner: LifecycleOwner) {
super.onResume(owner)
invalidate()
Handler(Looper.getMainLooper()).post {
invalidate()
}
}
})
setupListeners()
Expand All @@ -80,8 +84,10 @@ class CarStatsViewerScreen(carContext: CarContext) : Screen(carContext) {
private fun externalInvalidate() {
CoroutineScope(Dispatchers.IO).launch {
dataUpdate = true
delay(100)
invalidate()
delay(250)
Handler(Looper.getMainLooper()).post {
invalidate()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class TripDataSettingsScreen(carContext: CarContext) : Screen(carContext) {
private fun changeSelectedTrip(index: Int) {
CarStatsViewer.dataProcessor.changeSelectedTrip(index + 1)
CarStatsViewer.appPreferences.mainViewTrip = index
invalidate()
screenManager.popToRoot()
}
private fun tripTypeRow(tripType: Int) = Row.Builder().apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.ixam97.carStatsViewer.carApp

import android.os.Handler
import android.os.Looper
import androidx.annotation.OptIn
import androidx.car.app.CarToast
import androidx.car.app.annotations.ExperimentalCarApi
Expand Down Expand Up @@ -262,7 +264,11 @@ internal fun CarStatsViewerScreen.TripDataList() = ListTemplate.Builder().apply
setIcon(CarIcon.Builder(IconCompat.createWithResource(carContext, R.drawable.ic_car_app_tune)).build())
setBackgroundColor(CarColor.createCustom(backgroundColor, backgroundColor))
setOnClickListener {
screenManager.push(TripDataSettingsScreen(carContext))
screenManager.pushForResult(TripDataSettingsScreen(carContext)) {
Handler(Looper.getMainLooper()).post {
invalidate()
}
}
}
}.build())

Expand All @@ -272,7 +278,11 @@ internal fun CarStatsViewerScreen.TripDataList() = ListTemplate.Builder().apply
setIcon(CarIcon.Builder(IconCompat.createWithResource(carContext, R.drawable.ic_car_app_reset)).build())
setBackgroundColor(CarColor.createCustom(backgroundColor, backgroundColor))
setOnClickListener {
screenManager.push(ConfirmResetScreen(carContext))
screenManager.pushForResult(ConfirmResetScreen(carContext)) {
Handler(Looper.getMainLooper()).post {
invalidate()
}
}
}
}.build())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ class DataProcessor {
timerMap[tripType]?.reset()
loadSessionsToMemory().join()
if (drivingState == DrivingState.DRIVE) timerMap[tripType]?.start()
aaosExec?.execute(aaosRunnable)
}

private fun startChargingSession(): Job {
Expand Down

0 comments on commit 6e243b4

Please sign in to comment.