|
|
|
@ -11,6 +11,10 @@ import androidx.lifecycle.ViewModelProviders |
|
|
|
import androidx.recyclerview.widget.DiffUtil |
|
|
|
import androidx.recyclerview.widget.DiffUtil |
|
|
|
import com.crashlytics.android.Crashlytics |
|
|
|
import com.crashlytics.android.Crashlytics |
|
|
|
import kotlinx.android.synthetic.main.fragment_session.* |
|
|
|
import kotlinx.android.synthetic.main.fragment_session.* |
|
|
|
|
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
|
|
|
|
import kotlinx.coroutines.GlobalScope |
|
|
|
|
|
|
|
import kotlinx.coroutines.delay |
|
|
|
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.calculus.bankroll.BankrollReportManager |
|
|
|
import net.pokeranalytics.android.calculus.bankroll.BankrollReportManager |
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
@ -31,6 +35,7 @@ import net.pokeranalytics.android.ui.view.RowRepresentable |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentableDiffCallback |
|
|
|
import net.pokeranalytics.android.ui.view.RowRepresentableDiffCallback |
|
|
|
import net.pokeranalytics.android.ui.view.SmoothScrollLinearLayoutManager |
|
|
|
import net.pokeranalytics.android.ui.view.SmoothScrollLinearLayoutManager |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow |
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.SessionRow |
|
|
|
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.TransactionRow |
|
|
|
import net.pokeranalytics.android.ui.viewmodel.SessionViewModel |
|
|
|
import net.pokeranalytics.android.ui.viewmodel.SessionViewModel |
|
|
|
import net.pokeranalytics.android.util.extensions.findById |
|
|
|
import net.pokeranalytics.android.util.extensions.findById |
|
|
|
import net.pokeranalytics.android.util.extensions.getNextMinuteInMilliseconds |
|
|
|
import net.pokeranalytics.android.util.extensions.getNextMinuteInMilliseconds |
|
|
|
@ -226,20 +231,43 @@ class SessionFragment : RealmFragment(), RowRepresentableDelegate { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onRowValueChanged(value: Any?, row: RowRepresentable) { |
|
|
|
override fun onRowValueChanged(value: Any?, row: RowRepresentable) { |
|
|
|
sessionHasBeenUserCustomized = true |
|
|
|
this.sessionHasBeenUserCustomized = true |
|
|
|
try { |
|
|
|
try { |
|
|
|
currentSession.updateValue(value, row) |
|
|
|
this.currentSession.updateValue(value, row) |
|
|
|
} catch (e: PAIllegalStateException) { |
|
|
|
} catch (e: PAIllegalStateException) { |
|
|
|
Toast.makeText(context, e.message, Toast.LENGTH_LONG).show() |
|
|
|
Toast.makeText(context, e.message, Toast.LENGTH_LONG).show() |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
sessionAdapter.refreshRow(row) |
|
|
|
this.sessionAdapter.refreshRow(row) |
|
|
|
when (row) { |
|
|
|
when (row) { |
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE, SessionRow.NET_RESULT, SessionRow.BUY_IN, SessionRow.TIPS, |
|
|
|
SessionRow.CASHED_OUT, SessionRow.PRIZE, SessionRow.NET_RESULT, |
|
|
|
SessionRow.START_DATE, SessionRow.END_DATE, SessionRow.BANKROLL, SessionRow.BREAK_TIME -> updateSessionUI() |
|
|
|
SessionRow.BUY_IN, SessionRow.TIPS, SessionRow.START_DATE, |
|
|
|
|
|
|
|
SessionRow.END_DATE, SessionRow.BANKROLL, SessionRow.BREAK_TIME -> updateSessionUI() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Selects the next row to ease the data capture |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun selectNextRow(currentRow: RowRepresentable) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.viewModel.sessionId == null) { |
|
|
|
|
|
|
|
GlobalScope.launch(Dispatchers.Main) { |
|
|
|
|
|
|
|
delay(200) |
|
|
|
|
|
|
|
when (currentRow) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TransactionRow.BANKROLL -> onRowSelected(0, TransactionRow.TYPE) |
|
|
|
|
|
|
|
// TransactionRow.TYPE -> onRowSelected(0, TransactionRow.AMOUNT) |
|
|
|
|
|
|
|
// TransactionRow.AMOUNT -> onRowSelected(0, TransactionRow.DATE) |
|
|
|
|
|
|
|
// TransactionRow.DATE -> onRowSelected(0, TransactionRow.COMMENT) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Update the UI with the session data |
|
|
|
* Update the UI with the session data |
|
|
|
* Should be called after the initialization of the session |
|
|
|
* Should be called after the initialization of the session |
|
|
|
|