|
|
|
|
@ -5,6 +5,10 @@ import android.text.InputType |
|
|
|
|
import androidx.lifecycle.MutableLiveData |
|
|
|
|
import androidx.lifecycle.ViewModel |
|
|
|
|
import io.realm.Realm |
|
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
|
import kotlinx.coroutines.GlobalScope |
|
|
|
|
import kotlinx.coroutines.async |
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
|
import net.pokeranalytics.android.model.handhistory.HandSetup |
|
|
|
|
@ -24,6 +28,9 @@ import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
|
import net.pokeranalytics.android.util.extensions.formatted |
|
|
|
|
import timber.log.Timber |
|
|
|
|
import java.util.* |
|
|
|
|
import kotlin.collections.LinkedHashSet |
|
|
|
|
import kotlin.coroutines.CoroutineContext |
|
|
|
|
import kotlin.reflect.KClass |
|
|
|
|
|
|
|
|
|
enum class HHKeyboard { |
|
|
|
|
@ -40,6 +47,9 @@ interface PlayerSetupCreationListener { |
|
|
|
|
|
|
|
|
|
class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentralizer, ActionListListener { |
|
|
|
|
|
|
|
|
|
private val coroutineContext: CoroutineContext |
|
|
|
|
get() = Dispatchers.Main |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* The hand history |
|
|
|
|
*/ |
|
|
|
|
@ -595,12 +605,26 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
this.handHistory.actions.clear() |
|
|
|
|
val actions = this.sortedActions.map { it.action } |
|
|
|
|
this.handHistory.actions.addAll(actions) |
|
|
|
|
this.handHistory.defineWinnerPositions() |
|
|
|
|
|
|
|
|
|
if (!this.handHistory.isManaged) { |
|
|
|
|
realm.copyToRealmOrUpdate(this.handHistory) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.defineWinnerPositions() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun defineWinnerPositions() { |
|
|
|
|
|
|
|
|
|
GlobalScope.launch(coroutineContext) { |
|
|
|
|
GlobalScope.async { |
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
realm.executeTransaction { |
|
|
|
|
handHistory.defineWinnerPositions() |
|
|
|
|
} |
|
|
|
|
realm.close() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Card Centralizer |
|
|
|
|
|