Skip to content

Commit

Permalink
🐛 Fix crash on check-in to manual trips
Browse files Browse the repository at this point in the history
fixes #359
  • Loading branch information
jheubuch committed Jun 28, 2024
1 parent c822b0f commit d1e4bec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ data class StatusPointCalculation(
@SerializedName("base") val base: Float,
@SerializedName("distance") val distance: Float,
@SerializedName("factor") val factor: Float,
@SerializedName("reason") val reason: PointReason
)
@SerializedName("reason") val reason: PointReason?
) {
val safeReason get() = reason ?: PointReason.UNKNOWN
}

@Suppress("unused")
enum class PointReason {
Expand All @@ -32,6 +34,13 @@ enum class PointReason {
@SerializedName("3")
FORCED {
override fun getExplanation() = R.string.point_reason_forced
},
@SerializedName("4")
MANUAL {
override fun getExplanation() = R.string.point_reason_manual
},
UNKNOWN {
override fun getExplanation() = null
};

abstract fun getExplanation(): Int?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private fun SuccessfulCheckInResult(
isOwnStatus = true,
defaultVisibility = loggedInUserViewModel.defaultStatusVisibility
)
val pointReasonText = checkInResponse.data.points.calculation.reason.getExplanation()
val pointReasonText = checkInResponse.data.points.calculation.safeReason.getExplanation()
if (pointReasonText != null) {
Text(
modifier = Modifier.fillMaxWidth(),
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@
Punkte zu erhalten.
</string>
<string name="point_reason_forced">
Weil du diesen Check-In erzwungen hast, hast du nur 0 Punkte erhalten.
Weil du diesen Check-In erzwungen hast, hast du nicht alle Punkte erhalten.
</string>
<string name="point_reason_manual">
Weil du in eine manuell erstellte Fahrt eingecheckt hast, hast du keine Punkte erhalten.
</string>
<string name="title_share">Teilen</string>
<string name="or">oder</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
<string name="point_reason_forced">
Because you forced this check-in, you received 0 points.
</string>
<string name="point_reason_manual">
Because you checked into a manual trip, you received 0 points.
</string>
<string name="title_share">Share</string>
<string name="version_with_code" translatable="false">v%1$s (%2$d)</string>
<string name="or">or</string>
Expand Down

0 comments on commit d1e4bec

Please sign in to comment.