From a27745bcc7c0aba907f23643b39ae787e79224ae Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 15 Apr 2019 19:40:18 +0200 Subject: [PATCH] merge cherry-picking --- app/build.gradle | 4 ++++ .../android/model/realm/Session.kt | 23 +++++++++++-------- .../BottomSheetNumericTextFragment.kt | 10 +++++--- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 18f07644..065fb234 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -28,7 +28,11 @@ android { applicationId "net.pokeranalytics.android" minSdkVersion 23 targetSdkVersion 28 +<<<<<<< HEAD versionCode 8 +======= + versionCode 15 +>>>>>>> f5b9190... Fixes more crashes versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt b/app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt index d2f5125e..a5fff629 100644 --- a/app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt +++ b/app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt @@ -649,14 +649,9 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat SessionRow.BANKROLL -> bankroll?.name ?: NULL_TEXT SessionRow.BLINDS -> getFormattedBlinds() SessionRow.BREAK_TIME -> if (this.breakDuration > 0.0) this.breakDuration.toMinutes() else NULL_TEXT -<<<<<<< HEAD SessionRow.BUY_IN -> this.result?.buyin?.toCurrency(currency) ?: NULL_TEXT - SessionRow.CASHED_OUT, SessionRow.PRIZE, SessionRow.NET_RESULT -> this.result?.cashout?.toCurrency(currency) ?: NULL_TEXT -======= - SessionRow.BUY_IN -> this.result?.buyin?.toCurrency(CurrencyUtils.getCurrency(bankroll)) ?: NULL_TEXT - SessionRow.CASHED_OUT, SessionRow.PRIZE -> this.result?.cashout?.toCurrency(CurrencyUtils.getCurrency(bankroll)) ?: NULL_TEXT - SessionRow.NET_RESULT -> this.result?.netResult?.toCurrency(CurrencyUtils.getCurrency(bankroll)) ?: NULL_TEXT ->>>>>>> 0eba63f... Harmonizing number capture and management + fixing crashes + SessionRow.CASHED_OUT, SessionRow.PRIZE -> this.result?.cashout?.toCurrency(currency) ?: NULL_TEXT + SessionRow.NET_RESULT -> this.result?.netResult?.toCurrency(currency) ?: NULL_TEXT SessionRow.COMMENT -> if (this.comment.isNotEmpty()) this.comment else NULL_TEXT SessionRow.END_DATE -> this.endDate?.shortDateTime() ?: NULL_TEXT SessionRow.GAME -> getFormattedGame() @@ -830,10 +825,20 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat } SessionRow.INITIAL_BUY_IN -> tournamentEntryFee = if (value == null) null else (value as String).toDouble() SessionRow.LOCATION -> location = value as Location? - SessionRow.PLAYERS -> tournamentNumberOfPlayers = if (value != null) (value as String).toInt() else null + SessionRow.PLAYERS -> { + if (value is Double) { + this.tournamentNumberOfPlayers = value.toInt() + } else { + this.tournamentNumberOfPlayers = null + } + } SessionRow.POSITION -> { val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) - localResult.tournamentFinalPosition = if (value == null) null else (value as String).toInt() + if (value is Double) { + localResult.tournamentFinalPosition = value.toInt() + } else { + localResult.tournamentFinalPosition = null + } result = localResult } SessionRow.START_DATE -> if (value is Date) { diff --git a/app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetNumericTextFragment.kt b/app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetNumericTextFragment.kt index 8e953d6c..da9486d5 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetNumericTextFragment.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetNumericTextFragment.kt @@ -61,9 +61,13 @@ class BottomSheetNumericTextFragment : BottomSheetFragment() { } data[0].defaultValue?.let { - val formatter = NumberFormat.getNumberInstance() - formatter.isGroupingUsed = false - editText1.setText(formatter.format(it)) + if (it is Double || it is Long) { + val formatter = NumberFormat.getNumberInstance() + formatter.isGroupingUsed = false + editText1.setText(formatter.format(it)) + } else { + editText1.setText(it.toString()) + } } editText1.setOnEditorActionListener { _, actionId, _ ->