Skip to content

Commit

Permalink
Fix empty past trip list crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Ixam97 committed Aug 20, 2024
1 parent 6ec2de9 commit db3b877
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions automotive/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
defaultConfig {
minSdkVersion 29
targetSdkVersion 34
versionCode 267
versionName "0.28.0.0000"
versionCode 268
versionName "0.28.0.0001"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,21 @@ class TripHistoryScreen(carContext: CarContext):
pastDrivingSessions.addAll(CarStatsViewer.tripDataSource.getPastDrivingSessions())
pastDrivingSessions.sortByDescending { it.driving_session_id }

pastDrivingSessions.apply {
clear()
val trips = CarStatsViewer.tripDataSource.getPastDrivingSessions()
addAll(trips.subList(0, (trips.size - 1).coerceAtMost(49)))
sortByDescending { it.driving_session_id }

if (!showManualTrips) { removeIf { it.session_type == TripType.MANUAL } }
if (!showSinceChargeTrips) { removeIf { it.session_type == TripType.SINCE_CHARGE } }
if (!showAutomaticTrips) { removeIf { it.session_type == TripType.AUTO } }
if (!showMonthlyTrips) { removeIf { it.session_type == TripType.MONTH } }
if (pastDrivingSessions.isNotEmpty()) {
pastDrivingSessions.apply {
clear()
val trips = CarStatsViewer.tripDataSource.getPastDrivingSessions().sortedByDescending { it.driving_session_id }
addAll(trips.subList(0, (trips.size).coerceAtMost(49)))
// sortByDescending { it.driving_session_id }

if (!showManualTrips) { removeIf { it.session_type == TripType.MANUAL } }
if (!showSinceChargeTrips) { removeIf { it.session_type == TripType.SINCE_CHARGE } }
if (!showAutomaticTrips) { removeIf { it.session_type == TripType.AUTO } }
if (!showMonthlyTrips) { removeIf { it.session_type == TripType.MONTH } }
}
}


contentLoaded = true
withContext(Dispatchers.Main) {
invalidate()
Expand Down
2 changes: 2 additions & 0 deletions automotive/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@
</string-array>

<string-array translatable="false" name="pending_changes">
<item>(Play Edition) Re-Added trip history, but with limited information for now.</item>
<item>[V](0.28.0)</item>
</string-array>

<string name="file_name_current_trip_data" translatable="false">CurrentTripData</string>
Expand Down

0 comments on commit db3b877

Please sign in to comment.