Small refactoring

od
Laurent 6 years ago
parent 6d4b17aff3
commit f32d8eee3c
  1. 1
      app/src/main/java/net/pokeranalytics/android/model/realm/Transaction.kt
  2. 16
      app/src/main/java/net/pokeranalytics/android/ui/fragment/data/TransactionDataFragment.kt

@ -175,5 +175,4 @@ open class Transaction : RealmObject(), Manageable, StaticRowRepresentableDataSo
return DefaultLegendValues(this.entryTitle(context), entryValue, totalStatValue, leftName = leftName) return DefaultLegendValues(this.entryTitle(context), entryValue, totalStatValue, leftName = leftName)
} }
} }

@ -43,7 +43,7 @@ class TransactionDataFragment : EditableDataFragment(), StaticRowRepresentableDa
} }
override fun adapterRows(): List<RowRepresentable>? { override fun adapterRows(): List<RowRepresentable>? {
return transaction.adapterRows() return this.transaction.adapterRows()
} }
override fun stringForRow(row: RowRepresentable): String { override fun stringForRow(row: RowRepresentable): String {
@ -93,12 +93,19 @@ class TransactionDataFragment : EditableDataFragment(), StaticRowRepresentableDa
override fun onRowValueChanged(value: Any?, row: RowRepresentable) { override fun onRowValueChanged(value: Any?, row: RowRepresentable) {
super.onRowValueChanged(value, row) super.onRowValueChanged(value, row)
rowRepresentableAdapter.refreshRow(row) this.rowRepresentableAdapter.refreshRow(row)
this.selectNextRow(row)
}
/***
* Selects the next row to ease the data capture
*/
private fun selectNextRow(currentRow: RowRepresentable) {
if (viewModel.primaryKey == null) { // automatically change the row for new data if (this.viewModel.primaryKey == null) {
GlobalScope.launch(Dispatchers.Main) { GlobalScope.launch(Dispatchers.Main) {
delay(200) delay(200)
when (row) { when (currentRow) {
TransactionRow.BANKROLL -> onRowSelected(0, TransactionRow.TYPE) TransactionRow.BANKROLL -> onRowSelected(0, TransactionRow.TYPE)
TransactionRow.TYPE -> onRowSelected(0, TransactionRow.AMOUNT) TransactionRow.TYPE -> onRowSelected(0, TransactionRow.AMOUNT)
// TransactionRow.AMOUNT -> onRowSelected(0, TransactionRow.DATE) // TransactionRow.AMOUNT -> onRowSelected(0, TransactionRow.DATE)
@ -106,6 +113,7 @@ class TransactionDataFragment : EditableDataFragment(), StaticRowRepresentableDa
} }
} }
} }
} }
override fun willSaveData() { override fun willSaveData() {

Loading…
Cancel
Save