parent
41e7532ef1
commit
b9a5fc5ba6
@ -0,0 +1,88 @@ |
|||||||
|
package net.pokeranalytics.android.ui.view.rowrepresentable |
||||||
|
|
||||||
|
import android.text.InputType |
||||||
|
import io.realm.RealmResults |
||||||
|
import net.pokeranalytics.android.R |
||||||
|
import net.pokeranalytics.android.ui.fragment.components.bottomsheet.BottomSheetType |
||||||
|
import net.pokeranalytics.android.ui.view.DefaultEditable |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentable |
||||||
|
import net.pokeranalytics.android.ui.view.RowRepresentableEditDescriptor |
||||||
|
import net.pokeranalytics.android.ui.view.RowViewType |
||||||
|
import timber.log.Timber |
||||||
|
|
||||||
|
|
||||||
|
enum class TransactionRow : RowRepresentable, DefaultEditable { |
||||||
|
BANKROLL, |
||||||
|
TYPE, |
||||||
|
AMOUNT, |
||||||
|
COMMENT, |
||||||
|
DATE; |
||||||
|
|
||||||
|
override val resId: Int? |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
BANKROLL -> R.string.bankroll |
||||||
|
TYPE -> R.string.type |
||||||
|
AMOUNT -> R.string.amount |
||||||
|
COMMENT -> R.string.comment |
||||||
|
DATE -> R.string.date |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override val viewType: Int |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
BANKROLL -> RowViewType.TITLE_VALUE.ordinal |
||||||
|
TYPE -> RowViewType.TITLE_VALUE.ordinal |
||||||
|
AMOUNT -> RowViewType.TITLE_VALUE.ordinal |
||||||
|
COMMENT -> RowViewType.TITLE_VALUE.ordinal |
||||||
|
DATE -> RowViewType.TITLE_VALUE.ordinal |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override val bottomSheetType: BottomSheetType |
||||||
|
get() { |
||||||
|
return when (this) { |
||||||
|
BANKROLL -> BottomSheetType.LIST |
||||||
|
TYPE -> BottomSheetType.LIST |
||||||
|
AMOUNT -> BottomSheetType.EDIT_TEXT |
||||||
|
COMMENT -> BottomSheetType.EDIT_TEXT_MULTI_LINES |
||||||
|
DATE -> BottomSheetType.NONE |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun editingDescriptors(map: Map<String, Any?>): ArrayList<RowRepresentableEditDescriptor>? { |
||||||
|
Timber.d("editingDescriptors") |
||||||
|
return when (this) { |
||||||
|
BANKROLL -> { |
||||||
|
val defaultValue : Any? by map |
||||||
|
val data : RealmResults<*>? by map |
||||||
|
arrayListOf( |
||||||
|
RowRepresentableEditDescriptor(defaultValue, data = data) |
||||||
|
) |
||||||
|
} |
||||||
|
TYPE -> { |
||||||
|
val defaultValue : Any? by map |
||||||
|
val data : RealmResults<*>? by map |
||||||
|
arrayListOf( |
||||||
|
RowRepresentableEditDescriptor(defaultValue, data = data) |
||||||
|
) |
||||||
|
} |
||||||
|
AMOUNT -> { |
||||||
|
val defaultValue: String? by map |
||||||
|
arrayListOf( |
||||||
|
RowRepresentableEditDescriptor( |
||||||
|
defaultValue, |
||||||
|
inputType = InputType.TYPE_CLASS_NUMBER |
||||||
|
or InputType.TYPE_NUMBER_FLAG_DECIMAL |
||||||
|
or InputType.TYPE_NUMBER_FLAG_SIGNED |
||||||
|
)) |
||||||
|
} |
||||||
|
COMMENT -> { |
||||||
|
val defaultValue : String? by map |
||||||
|
arrayListOf(RowRepresentableEditDescriptor(defaultValue, R.string.comment)) |
||||||
|
} |
||||||
|
else -> super<RowRepresentable>.editingDescriptors(map) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue