Add transaction row (additive)

dev
Aurelien Hubert 7 years ago
parent 9315431adc
commit 51bf2481a9
  1. 8
      app/src/main/java/net/pokeranalytics/android/model/realm/TransactionType.kt
  2. 29
      app/src/main/java/net/pokeranalytics/android/ui/view/rowrepresentable/TransactionTypeRow.kt

@ -69,6 +69,13 @@ open class TransactionType : RealmObject(), NameManageable, StaticRowRepresentab
} }
} }
override fun boolForRow(row: RowRepresentable): Boolean {
return when (row) {
TransactionTypeRow.TRANSACTION_ADDITIVE -> this.additive
else -> super.boolForRow(row)
}
}
override fun editDescriptors(row: RowRepresentable): ArrayList<RowRepresentableEditDescriptor>? { override fun editDescriptors(row: RowRepresentable): ArrayList<RowRepresentableEditDescriptor>? {
return row.editingDescriptors(mapOf("defaultValue" to this.name)) return row.editingDescriptors(mapOf("defaultValue" to this.name))
} }
@ -76,6 +83,7 @@ open class TransactionType : RealmObject(), NameManageable, StaticRowRepresentab
override fun updateValue(value: Any?, row: RowRepresentable) { override fun updateValue(value: Any?, row: RowRepresentable) {
when (row) { when (row) {
SimpleRow.NAME -> this.name = value as String? ?: "" SimpleRow.NAME -> this.name = value as String? ?: ""
TransactionTypeRow.TRANSACTION_ADDITIVE -> this.additive = value as Boolean? ?: false
} }
} }

@ -1,6 +1,33 @@
package net.pokeranalytics.android.ui.view.rowrepresentable package net.pokeranalytics.android.ui.view.rowrepresentable
import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType
import net.pokeranalytics.android.ui.view.DefaultEditDataSource import net.pokeranalytics.android.ui.view.DefaultEditDataSource
import net.pokeranalytics.android.ui.view.RowRepresentable import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType
enum class TransactionTypeRow : RowRepresentable, DefaultEditDataSource enum class TransactionTypeRow : RowRepresentable, DefaultEditDataSource {
TRANSACTION_ADDITIVE;
override val resId: Int?
get() {
return when (this) {
TRANSACTION_ADDITIVE -> R.string.additive
}
}
override val viewType: Int
get() {
return when (this) {
TRANSACTION_ADDITIVE -> RowViewType.TITLE_SWITCH.ordinal
}
}
override val bottomSheetType: BottomSheetType
get() {
return when (this) {
TRANSACTION_ADDITIVE -> BottomSheetType.NONE
}
}
}

Loading…
Cancel
Save