private String getIngredientList(String[][] array) { String ingredientList = ""; String measurement = ""; for (int i = 0; i < array.length; i++) { measurement = array[i][MEASUREMENT]; // adds the plural's' to the end of measurement if (nutrition.amountToFloat(array[i][AMOUNT]) > 1) measurement += "s"; // screens the possibility that no unit is needed if (measurement.equalsIgnoreCase("no unit") || measurement.equalsIgnoreCase("no units")) measurement = ""; else measurement += " of"; ingredientList += "> " + array[i][AMOUNT] + " " + measurement + " " + array[i][DESCRIPTION] + " " + array[i][INGREDIENTNAME] + "\n"; } return ingredientList; }
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { tempArray = stringCopy(ingredientArray, ingredientNum); // inc progress b/c we dont want it to be 0 progress++; if (progress > 0) { txtServings.setText(Integer.toString(progress)); for (int i = 0; i < tempArray.length; i++) { float am = nutrition.amountToFloat(tempArray[i][AMOUNT]); float serv = progress / Float.valueOf(servings); // Log.d("seekbar in for", "am= "+am+", serv="+serv); tempArray[i][AMOUNT] = nutrition.amountToString(am * serv); } txtIngredientList.setText(getIngredientList(tempArray)); } }