Skip to content

Commit

Permalink
Merge pull request #18 from RaiderRobotix/develop
Browse files Browse the repository at this point in the history
Fix auto populate issues from v3.01
  • Loading branch information
spencerng authored Feb 6, 2019
2 parents f17cce7 + 15f0357 commit f49f0eb
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 92 deletions.
2 changes: 1 addition & 1 deletion scoutingapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName '3.01'
versionName '3.02'
multiDexEnabled true


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

private void crossHabLineState() {
if (rocketCargo.getValue() > 0 || cargoShipCargo.getValue() > 0
|| rocketHatches.getValue() > 0 || sideCargoShipHatchCapable.isChecked() ||
|| cargoShipHatches.getValue() > 0 || rocketHatches.getValue() > 0 || sideCargoShipHatchCapable.isChecked() ||
frontCargoShipHatchCapable.isChecked() || opponentCargoShipLineFoul.isChecked()) {
reachHabLine.setChecked(true);
reachHabLine.setEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,95 +64,6 @@ public void setEntry(ScoutEntry entry) {
this.entry = entry;
}

@Override
public void autoPopulate() {
if (entry.getTeleOp() != null) {
TeleOp tele = entry.getTeleOp();

cargoShipHatches.setValue(tele.getCargoShipHatches());
rocketLevelOneHatches.setValue(tele.getCargoShipCargo());
rocketLevelOneCargo.setValue(tele.getRocketLevelOneCargo());
cargoShipCargo.setValue(tele.getRocketLevelOneHatches());
rocketLevelTwoCargo.setValue(tele.getRocketLevelTwoCargo());
rocketLevelTwoHatches.setValue(tele.getRocketLevelTwoHatches());
rocketLevelThreeCargo.setValue(tele.getRocketLevelThreeCargo());
rocketLevelThreeHatches.setValue(tele.getRocketLevelThreeHatches());

climbAssistedByPartners.setChecked(tele.isClimbAssistedByPartners());
partnerClimbsAssisted.setValue(tele.getNumberOfPartnerClimbsAssisted());
hatchesDropped.setValue(tele.getHatchesDropped());
cargoDropped.setValue(tele.getCargoDropped());
attemptHabClimb.setChecked(tele.isAttemptHabClimb());
successHabClimb.setChecked(tele.isSuccessHabClimb());

if (tele.getAssistingClimbTeamNumber() != 0) {
teamNumberThatAssistedClimb.setText(Integer.toString(tele.getAssistingClimbTeamNumber()));
}

for (int i = 2; i <= 3; i++) {
if (i == tele.getHighestClimbAssisted()) {
highestAssistedClimbLevel[i - 2].setChecked(true);
}
}

for (int i = 1; i <= successHabClimbLevel.length; i++) {
if (i == tele.getSuccessHabClimbLevel()) {
successHabClimbLevel[i - 1].setChecked(true);
}
}

for (int i = 1; i <= attemptHabClimbLevel.length; i++) {
if (i == tele.getAttemptHabClimbLevel()) {
attemptHabClimbLevel[i - 1].setChecked(true);
}
}

if (partnerClimbsAssisted.getValue() >= 1) {
radioButtonEnable(highestAssistedClimbLevelGroup, true);
}

autoDisableSuccessGroup();

}
}

@Override
public void saveState() {

entry.setTeleOp(new TeleOp(cargoShipHatches.getValue(),
cargoShipCargo.getValue(),
rocketLevelOneCargo.getValue(),
rocketLevelOneHatches.getValue(),
rocketLevelTwoCargo.getValue(),
rocketLevelTwoHatches.getValue(),
rocketLevelThreeCargo.getValue(),
rocketLevelThreeHatches.getValue(),
hatchesDropped.getValue(),
cargoDropped.getValue(),
climbAssistedByPartners.isChecked(),
getHabLevelSelected(attemptHabClimbLevel),
getHabLevelSelected(successHabClimbLevel),
attemptHabClimb.isChecked(),
successHabClimb.isChecked(),
getIntegerFromTextBox(teamNumberThatAssistedClimb),
partnerClimbsAssisted.getValue(),
getHighestHabLevelSelected(highestAssistedClimbLevel)));

}

public static void radioButtonEnable(RadioGroup groupToEnableOrDisable, boolean modeSelected) {
if (modeSelected) {
for (int i = 0; i < groupToEnableOrDisable.getChildCount(); i++) {
groupToEnableOrDisable.getChildAt(i).setEnabled(true);
}
} else {
for (int i = 0; i < groupToEnableOrDisable.getChildCount(); i++) {
groupToEnableOrDisable.getChildAt(i).setEnabled(false);
groupToEnableOrDisable.clearCheck();
}
}
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Expand Down Expand Up @@ -252,6 +163,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

});

autoPopulate();

continueButton.setOnClickListener(view1 -> {
hideKeyboard();
Expand Down Expand Up @@ -283,6 +195,95 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
return view;
}

@Override
public void saveState() {

entry.setTeleOp(new TeleOp(cargoShipHatches.getValue(),
cargoShipCargo.getValue(),
rocketLevelOneCargo.getValue(),
rocketLevelOneHatches.getValue(),
rocketLevelTwoCargo.getValue(),
rocketLevelTwoHatches.getValue(),
rocketLevelThreeCargo.getValue(),
rocketLevelThreeHatches.getValue(),
hatchesDropped.getValue(),
cargoDropped.getValue(),
climbAssistedByPartners.isChecked(),
getHabLevelSelected(attemptHabClimbLevel),
getHabLevelSelected(successHabClimbLevel),
attemptHabClimb.isChecked(),
successHabClimb.isChecked(),
getIntegerFromTextBox(teamNumberThatAssistedClimb),
partnerClimbsAssisted.getValue(),
getHighestHabLevelSelected(highestAssistedClimbLevel)));

}

public static void radioButtonEnable(RadioGroup groupToEnableOrDisable, boolean modeSelected) {
if (modeSelected) {
for (int i = 0; i < groupToEnableOrDisable.getChildCount(); i++) {
groupToEnableOrDisable.getChildAt(i).setEnabled(true);
}
} else {
for (int i = 0; i < groupToEnableOrDisable.getChildCount(); i++) {
groupToEnableOrDisable.getChildAt(i).setEnabled(false);
groupToEnableOrDisable.clearCheck();
}
}
}

@Override
public void autoPopulate() {
if (entry.getTeleOp() != null) {
TeleOp tele = entry.getTeleOp();

cargoShipHatches.setValue(tele.getCargoShipHatches());
cargoShipCargo.setValue(tele.getCargoShipCargo());
rocketLevelOneCargo.setValue(tele.getRocketLevelOneCargo());
rocketLevelOneHatches.setValue(tele.getRocketLevelOneHatches());
rocketLevelTwoCargo.setValue(tele.getRocketLevelTwoCargo());
rocketLevelTwoHatches.setValue(tele.getRocketLevelTwoHatches());
rocketLevelThreeCargo.setValue(tele.getRocketLevelThreeCargo());
rocketLevelThreeHatches.setValue(tele.getRocketLevelThreeHatches());

climbAssistedByPartners.setChecked(tele.isClimbAssistedByPartners());
partnerClimbsAssisted.setValue(tele.getNumberOfPartnerClimbsAssisted());
hatchesDropped.setValue(tele.getHatchesDropped());
cargoDropped.setValue(tele.getCargoDropped());
attemptHabClimb.setChecked(tele.isAttemptHabClimb());
successHabClimb.setChecked(tele.isSuccessHabClimb());

if (tele.getAssistingClimbTeamNumber() != 0) {
teamNumberThatAssistedClimb.setText(Integer.toString(tele.getAssistingClimbTeamNumber()));
}

for (int i = 2; i <= 3; i++) {
if (i == tele.getHighestClimbAssisted()) {
highestAssistedClimbLevel[i - 2].setChecked(true);
}
}

for (int i = 1; i <= successHabClimbLevel.length; i++) {
if (i == tele.getSuccessHabClimbLevel()) {
successHabClimbLevel[i - 1].setChecked(true);
}
}

for (int i = 1; i <= attemptHabClimbLevel.length; i++) {
if (i == tele.getAttemptHabClimbLevel()) {
attemptHabClimbLevel[i - 1].setChecked(true);
}
}

if (partnerClimbsAssisted.getValue() >= 1) {
radioButtonEnable(highestAssistedClimbLevelGroup, true);
}

autoDisableSuccessGroup();

}
}

public static boolean checkIfButtonIsChecked(RadioButton[] groupToCheck) {
for (RadioButton button : groupToCheck) {
if (button.isChecked()) {
Expand Down
2 changes: 1 addition & 1 deletion scoutingapp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
note that there is no trailing zero for the patch version. Tags on GitHub follow the same scheme,
except the letter "v" is appended to the version number.
Version 1.0 was created for the 2017 FRC season (FIRST Steamworks).-->
<string name="version_number">v3.01</string>
<string name="version_number">v3.02</string>

<!-- Name of the cheatsheet file in /assets-->
<string name="cheatsheet_filename">Deep Space Cheatsheet.pdf</string>
Expand Down

0 comments on commit f49f0eb

Please sign in to comment.