/** * Clear the unit selection for unit type fragment at position pos * * @param unitTypeFragPos the position of the desired unit type fragment * from which to clear selected units */ private void clearUnitSelection(int unitTypeFragPos) { ConvKeysFragment currFragAtPos = getConvKeyFrag(unitTypeFragPos); if (currFragAtPos != null) currFragAtPos.clearButtonSelection(); }
private void tryConvert(int buttonPos) { //Clear color and arrows from previously selected convert buttons clearButtonSelection(); //Set select unit, also this will potentially call convert if we already have a selected unit boolean requestConvert = mUnitType.selectUnit(buttonPos); Calculator calc = Calculator.getCalculator(getActivity()); //unit previously selected, we pressed another, do a convert if (requestConvert){ calc.convertFromTo(mUnitType.getPrevUnit(), mUnitType.getCurrUnit()); clearButtonSelection(); } //unit not previously selected, now select one else if (mUnitType.isUnitSelected()){ // clear out solved flag calc.setSolved(false); //if expression was blank, add a highlighted "1" if (calc.isExpressionEmpty()){ //add in a 1 for user's convenience calc.parseKeyPressed("1"); //highlight it calc.setSelection(0, calc.toString().length()); } colorSelectedButton(); } //always update screen to add/remove unit from expression mCallback.updateScreen(true); }