private void savePreferences() { RobopongApp.UserPrefs prefs = RobopongApp.getUserPrefs(); prefs.mOsciValues = mSpeedOsciConfig.getPosValues(); prefs.mOsciRangeOffset = mSpeedOsciConfig.getPosRangeOffset(); prefs.mSpeedValues = mSpeedOsciConfig.getSpeedValues(); prefs.mSpeedRangeOffset = mSpeedOsciConfig.getSpeedRangeOffset(); prefs.mHeadAngle = mSpeedOsciConfig.getAngle(); prefs.writeSettings(); }
private void createExercise() { int[] speedValues = mSpeedOsciConfig.getSpeedValues(); int speedRangeOffset = mSpeedOsciConfig.getSpeedRangeOffset(); int[] posValues = mSpeedOsciConfig.getPosValues(); int posRangeOffset = mSpeedOsciConfig.getPosRangeOffset(); int waitBetweenBallsMs = RobopongApp.getUserPrefs().getTimeAfterBallMs(); // TODO consider knob double angle = mSpeedOsciConfig.getAngle(); mExercise = new Exercise(); mExercise.setId("MANUAL_42"); // NON-NLS mExercise.setTitle("Manual Drill"); // NON-NLS RangeType range = new RangeType("" + (int) angle); mExercise.setAngle(range); if (speedValues.length > 0) { ChoicesStep choicesStep = new ChoicesStep(); int choicePercentage = 100 / speedValues.length; for (int speedValue : speedValues) { SpeedStep step = new SpeedStep(); step.setChoicePercentage(choicePercentage); range = new RangeType(speedValue, speedRangeOffset); step.setSpeed(range); choicesStep.addStep(step); } if (choicesStep.getSteps().size() > 1) { mExercise.addStep(choicesStep); } else if (choicesStep.getSteps().size() == 1) { mExercise.addStep(choicesStep.getSteps().get(0)); } } if (posValues.length > 0) { ChoicesStep choicesStep = new ChoicesStep(); int choicePercentage = 100 / posValues.length; for (int posValue : posValues) { PosStep step = new PosStep(); step.setChoicePercentage(choicePercentage); range = new RangeType(posValue, posRangeOffset); step.setPos(range); choicesStep.addStep(step); } if (choicesStep.getSteps().size() > 1) { mExercise.addStep(choicesStep); } else if (choicesStep.getSteps().size() == 1) { mExercise.addStep(choicesStep.getSteps().get(0)); } } PlayBallStep st = new PlayBallStep(); st.setWaitAfterMs(waitBetweenBallsMs); st.setPos(null); st.setSpeed(null); st.setNoOfBalls(new RangeType("1")); mExercise.addStep(st); }