|
|
|
@ -21,13 +21,14 @@ import net.pokeranalytics.android.ui.view.rowrepresentable.CustomFieldRow |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SimpleRow |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SimpleRow |
|
|
|
import net.pokeranalytics.android.util.enumerations.IntIdentifiable |
|
|
|
import net.pokeranalytics.android.util.enumerations.IntIdentifiable |
|
|
|
|
|
|
|
import timber.log.Timber |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
import kotlin.collections.ArrayList |
|
|
|
import kotlin.collections.ArrayList |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
open class CustomField : RealmObject(), NameManageable, StaticRowRepresentableDataSource, RowRepresentable { |
|
|
|
open class CustomField : RealmObject(), NameManageable, StaticRowRepresentableDataSource, RowRepresentable { |
|
|
|
|
|
|
|
|
|
|
|
enum class Type(override var uniqueIdentifier: Int, var resId: Int) : IntIdentifiable { |
|
|
|
enum class Type(override var uniqueIdentifier: Int, var resId: Int, var isEnabled: Boolean = true) : IntIdentifiable { |
|
|
|
LIST(0, R.string.enum_custom_field_type), |
|
|
|
LIST(0, R.string.enum_custom_field_type), |
|
|
|
NUMBER(1, R.string.number), |
|
|
|
NUMBER(1, R.string.number), |
|
|
|
AMOUNT(2, R.string.amount) |
|
|
|
AMOUNT(2, R.string.amount) |
|
|
|
@ -75,11 +76,14 @@ open class CustomField : RealmObject(), NameManageable, StaticRowRepresentableDa |
|
|
|
//helper |
|
|
|
//helper |
|
|
|
|
|
|
|
|
|
|
|
val isListType: Boolean |
|
|
|
val isListType: Boolean |
|
|
|
get() { return this.type == Type.LIST.uniqueIdentifier } |
|
|
|
get() { |
|
|
|
|
|
|
|
return this.type == Type.LIST.uniqueIdentifier |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val isAmountType: Boolean |
|
|
|
val isAmountType: Boolean |
|
|
|
get() { return this.type == Type.AMOUNT.uniqueIdentifier } |
|
|
|
get() { |
|
|
|
|
|
|
|
return this.type == Type.AMOUNT.uniqueIdentifier |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun localizedTitle(context: Context): String { |
|
|
|
override fun localizedTitle(context: Context): String { |
|
|
|
return this.name |
|
|
|
return this.name |
|
|
|
@ -118,12 +122,13 @@ open class CustomField : RealmObject(), NameManageable, StaticRowRepresentableDa |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun isValidForDelete(context: Context, realm: Realm): Boolean { |
|
|
|
override fun isValidForDelete(context: Context, realm: Realm): Boolean { |
|
|
|
return true |
|
|
|
val sessions = realm.where<Session>().contains("customFieldEntries.customField.id", id).findAll() |
|
|
|
|
|
|
|
return sessions.isEmpty() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun getFailedDeleteMessage(status: DeleteValidityStatus): Int { |
|
|
|
override fun getFailedDeleteMessage(status: DeleteValidityStatus): Int { |
|
|
|
//TODO: |
|
|
|
//TODO: |
|
|
|
return R.string.relationship_error |
|
|
|
return R.string.cf_entry_delete_popup_message |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override val bottomSheetType: BottomSheetType |
|
|
|
override val bottomSheetType: BottomSheetType |
|
|
|
@ -247,6 +252,7 @@ open class CustomField : RealmObject(), NameManageable, StaticRowRepresentableDa |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
entriesToDelete.forEach { |
|
|
|
entriesToDelete.forEach { |
|
|
|
|
|
|
|
Timber.d("Delete entry: ${it.value} / ${it.id}") |
|
|
|
realm.where<CustomFieldEntry>().equalTo("id", it.id).findFirst()?.deleteFromRealm() |
|
|
|
realm.where<CustomFieldEntry>().equalTo("id", it.id).findFirst()?.deleteFromRealm() |
|
|
|
} |
|
|
|
} |
|
|
|
entriesToDelete.clear() |
|
|
|
entriesToDelete.clear() |
|
|
|
|