|
|
|
@ -2,15 +2,13 @@ package net.pokeranalytics.android.model.realm |
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
import io.realm.Realm |
|
|
|
import io.realm.Realm |
|
|
|
|
|
|
|
import io.realm.RealmModel |
|
|
|
import io.realm.RealmObject |
|
|
|
import io.realm.RealmObject |
|
|
|
import io.realm.annotations.Ignore |
|
|
|
import io.realm.annotations.Ignore |
|
|
|
import io.realm.annotations.PrimaryKey |
|
|
|
import io.realm.annotations.PrimaryKey |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
import net.pokeranalytics.android.model.interfaces.DeleteValidityStatus |
|
|
|
import net.pokeranalytics.android.model.interfaces.* |
|
|
|
import net.pokeranalytics.android.model.interfaces.Identifiable |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.interfaces.NameManageable |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.interfaces.SaveValidityStatus |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
|
|
|
import net.pokeranalytics.android.ui.adapter.StaticRowRepresentableDataSource |
|
|
|
import net.pokeranalytics.android.ui.view.Localizable |
|
|
|
import net.pokeranalytics.android.ui.view.Localizable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
@ -23,7 +21,8 @@ import java.util.* |
|
|
|
import kotlin.collections.ArrayList |
|
|
|
import kotlin.collections.ArrayList |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
open class TransactionType : RealmObject(), NameManageable, StaticRowRepresentableDataSource, RowRepresentable { |
|
|
|
open class TransactionType : RealmObject(), NameManageable, StaticRowRepresentableDataSource, RowRepresentable, |
|
|
|
|
|
|
|
CountableUsage { |
|
|
|
|
|
|
|
|
|
|
|
enum class Value(override var uniqueIdentifier: Int, val additive: Boolean) : IntIdentifiable, Localizable { |
|
|
|
enum class Value(override var uniqueIdentifier: Int, val additive: Boolean) : IntIdentifiable, Localizable { |
|
|
|
|
|
|
|
|
|
|
|
@ -69,21 +68,6 @@ open class TransactionType : RealmObject(), NameManageable, StaticRowRepresentab |
|
|
|
throw PAIllegalStateException("Transaction type ${value.name} should exist in database!") |
|
|
|
throw PAIllegalStateException("Transaction type ${value.name} should exist in database!") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun getOrCreateByValue(realm: Realm, context: Context, value: Value): TransactionType { |
|
|
|
|
|
|
|
val type = realm.where(TransactionType::class.java).equalTo("kind", value.uniqueIdentifier).findFirst() |
|
|
|
|
|
|
|
type?.let { |
|
|
|
|
|
|
|
return it |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val tt = TransactionType() |
|
|
|
|
|
|
|
tt.name = value.localizedTitle(context) |
|
|
|
|
|
|
|
tt.additive = value.additive |
|
|
|
|
|
|
|
tt.kind = value.uniqueIdentifier |
|
|
|
|
|
|
|
tt.lock = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return tt |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
@Ignore |
|
|
|
@ -109,6 +93,11 @@ open class TransactionType : RealmObject(), NameManageable, StaticRowRepresentab |
|
|
|
// The predefined kind, if necessary, like: Withdrawal, deposit, or tips |
|
|
|
// The predefined kind, if necessary, like: Withdrawal, deposit, or tips |
|
|
|
var kind: Int? = null |
|
|
|
var kind: Int? = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override var useCount: Int = 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
|
|
|
|
override val ownerClass: Class<out RealmModel> = Transaction::class.java |
|
|
|
|
|
|
|
|
|
|
|
override fun getDisplayName(context: Context): String { |
|
|
|
override fun getDisplayName(context: Context): String { |
|
|
|
return this.name |
|
|
|
return this.name |
|
|
|
} |
|
|
|
} |
|
|
|
|