Skip to content

Commit 2820bb6

Browse files
committed
Add usingMatchSchedule() and usingPitSchedule()
1 parent b769e78 commit 2820bb6

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

app/src/main/java/com/scouting/app/viewmodel/ScoutingViewModel.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,21 @@ class ScoutingViewModel : ViewModel() {
4646
var scoutName by mutableStateOf(TextFieldValue())
4747

4848
var showingNoTemplateDialog by mutableStateOf(false)
49+
var showingSelectPitDialog by mutableStateOf(false)
4950

5051
lateinit var scoutingScheduleManager: ScoutingScheduleManager
5152
private val preferences = MMKV.defaultMMKV()
5253

54+
/**
55+
* Indicate whether match scouting is currently using a schedule
56+
*/
57+
fun usingMatchSchedule(): Boolean = preferences.decodeBool("COMPETITION_MODE", false)
58+
59+
/**
60+
* Indicate whether pit scouting is currently using a schedule
61+
*/
62+
fun usingPitSchedule(): Boolean = preferences.decodeBool("PIT_SCOUTING_MODE", false)
63+
5364
/**
5465
* Deserialize template items from user-selected and created JSON template
5566
* to list variables stored in the ViewModel, to later be interpreted and
@@ -104,7 +115,7 @@ class ScoutingViewModel : ViewModel() {
104115
fun populateMatchData() {
105116
currentAllianceMonitoring =
106117
AllianceType.valueOf(preferences.decodeString("DEVICE_ALLIANCE_POSITION", "RED")!!)
107-
if (preferences.decodeBool("COMPETITION_MODE", false)) {
118+
if (usingMatchSchedule()) {
108119
currentMatchMonitoring =
109120
TextFieldValue((scoutingScheduleManager.currentMatchScoutingIteration + 1).toString())
110121
currentTeamNumberMonitoring = TextFieldValue(scoutingScheduleManager.getCurrentTeam())
@@ -120,7 +131,7 @@ class ScoutingViewModel : ViewModel() {
120131
* scouting mode is disabled.
121132
*/
122133
fun populatePitDataIfScheduled() {
123-
if (preferences.decodeBool("PIT_SCOUTING_MODE", false)) {
134+
if (usingPitSchedule()) {
124135
val teamInfo = scoutingScheduleManager.getCurrentPitInfo()
125136
currentTeamNameMonitoring = TextFieldValue(teamInfo.second)
126137
currentTeamNumberMonitoring = TextFieldValue(teamInfo.first)
@@ -211,11 +222,11 @@ class ScoutingViewModel : ViewModel() {
211222
}
212223

213224
if (scoutingType == PIT) {
214-
if (preferences.decodeBool("PIT_SCOUTING_MODE", false)) {
225+
if (usingPitSchedule()) {
215226
scoutingScheduleManager.moveToNextPit()
216227
}
217228
} else {
218-
if (preferences.decodeBool("COMPETITION_MODE", false)) {
229+
if (usingMatchSchedule()) {
219230
scoutingScheduleManager.moveToNextMatch()
220231
}
221232
}

0 commit comments

Comments
 (0)