Fixes more crashes

feature/top10
Laurent 7 years ago
parent 307e6d2b74
commit f5b9190583
  1. 2
      app/build.gradle
  2. 14
      app/src/main/java/net/pokeranalytics/android/model/realm/Session.kt
  3. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/components/bottomsheet/BottomSheetNumericTextFragment.kt

@ -28,7 +28,7 @@ android {
applicationId "net.pokeranalytics.android" applicationId "net.pokeranalytics.android"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 28 targetSdkVersion 28
versionCode 14 versionCode 15
versionName "1.0" versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

@ -802,10 +802,20 @@ open class Session : RealmObject(), Savable, Editable, StaticRowRepresentableDat
} }
SessionRow.INITIAL_BUY_IN -> tournamentEntryFee = if (value == null) null else (value as String).toDouble() SessionRow.INITIAL_BUY_IN -> tournamentEntryFee = if (value == null) null else (value as String).toDouble()
SessionRow.LOCATION -> location = value as Location? 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 -> { SessionRow.POSITION -> {
val localResult = if (result != null) result as Result else realm.createObject(Result::class.java) 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 result = localResult
} }
SessionRow.START_DATE -> if (value is Date) { SessionRow.START_DATE -> if (value is Date) {

@ -61,9 +61,13 @@ class BottomSheetNumericTextFragment : BottomSheetFragment() {
} }
data[0].defaultValue?.let { data[0].defaultValue?.let {
if (it is Double || it is Long) {
val formatter = NumberFormat.getNumberInstance() val formatter = NumberFormat.getNumberInstance()
formatter.isGroupingUsed = false formatter.isGroupingUsed = false
editText1.setText(formatter.format(it)) editText1.setText(formatter.format(it))
} else {
editText1.setText(it.toString())
}
} }
editText1.setOnEditorActionListener { _, actionId, _ -> editText1.setOnEditorActionListener { _, actionId, _ ->

Loading…
Cancel
Save