From ab9b7724c1ab63e810adef1cb1be9fefef737e19 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 5 Oct 2023 08:46:56 +0200 Subject: [PATCH] Fix crash --- .../android/model/realm/handhistory/HandHistory.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt index d4d5c85b..6ec84ade 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/HandHistory.kt @@ -754,9 +754,13 @@ open class HandHistory : RealmObject(), Deletable, RowRepresentable, Filterable, return cards.filter { it.isSuitWildCard } } - val largestWonPot: WonPot? + private val largestWonPot: WonPot? get() { - return this.winnerPots.maxBy { it.amount } + return if (this.winnerPots.isNotEmpty()) { // needed, otherwise maxBy crashes + this.winnerPots.maxBy { it.amount } + } else { + null + } } } \ No newline at end of file