Fixing crashes when adding a new player

hh
Laurent 6 years ago
parent 1a56c245b6
commit 5d048015d8
  1. 2
      app/src/main/java/net/pokeranalytics/android/model/realm/Player.kt
  2. 5
      app/src/main/java/net/pokeranalytics/android/ui/fragment/FeedFragment.kt
  3. 6
      app/src/main/java/net/pokeranalytics/android/ui/modules/datalist/DataListFragment.kt

@ -22,7 +22,7 @@ import net.pokeranalytics.android.util.extensions.mediumDate
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
open class Player : RealmObject(), NameManageable, Deletable, StaticRowRepresentableDataSource, RowRepresentable { open class Player : RealmObject(), NameManageable, Savable, Deletable, StaticRowRepresentableDataSource, RowRepresentable {
@PrimaryKey @PrimaryKey
override var id = UUID.randomUUID().toString() override var id = UUID.randomUUID().toString()

@ -466,10 +466,13 @@ class FeedFragment : FilterableFragment(), RowRepresentableDelegate {
* Create a new hand history * Create a new hand history
*/ */
private fun createNewHandHistory() { private fun createNewHandHistory() {
// gets the first session of the adapter - the last created - to preconfigure the HH // gets the first session of the adapter - the last created - to preconfigure the HH
if (this.sessionAdapter.itemCount > 0) {
this.sessionAdapter.sessionForPosition(0)?.let { session -> this.sessionAdapter.sessionForPosition(0)?.let { session ->
HandHistoryActivity.newInstance(this, session, false) HandHistoryActivity.newInstance(this, session, false)
} ?: run { } ?: throw PAIllegalStateException("Cannot happen")
} else {
HandHistoryActivity.newInstance(this) HandHistoryActivity.newInstance(this)
} }
} }

@ -169,7 +169,7 @@ open class DataListFragment : DeletableItemFragment(), RowRepresentableDelegate
RequestCode.NEW_DATA.value -> { RequestCode.NEW_DATA.value -> {
if (this.model.isSelectionInstance) { if (this.model.isSelectionInstance) {
data?.getStringExtra(BundleKey.PRIMARY_KEY.value)?.let { id -> data?.getStringExtra(EditableDataActivity.IntentKey.PRIMARY_KEY.keyName)?.let { id ->
finishActivityWithSelection(id) finishActivityWithSelection(id)
} ?: throw PAIllegalStateException("identifier not found") } ?: throw PAIllegalStateException("identifier not found")
@ -190,10 +190,6 @@ open class DataListFragment : DeletableItemFragment(), RowRepresentableDelegate
if (this.model.isSelectionInstance) { // Ends the activity and go back to previous screen if (this.model.isSelectionInstance) { // Ends the activity and go back to previous screen
val identifier = (row as Identifiable).id val identifier = (row as Identifiable).id
finishActivityWithSelection(identifier) finishActivityWithSelection(identifier)
// val intent = Intent()
// intent.putExtra(BundleKey.PRIMARY_KEY.value, identifier)
// this.activity?.setResult(Activity.RESULT_OK, intent)
// this.activity?.finish()
} else { } else {
when (this.model.dataType) { when (this.model.dataType) {

Loading…
Cancel
Save