Android Open Source - amulet Favourite Drink Utility






From Project

Back to project page amulet.

License

The source code is released under:

MIT License

If you think the Android project amulet listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package scamell.michael.amulet;
/*from   ww w.  j  a v a2 s  . c  o m*/

import android.content.Context;

import java.util.ArrayList;
import java.util.List;

public class FavouriteDrinkUtility {

    public static void saveFavouriteDrinkToStorage(Context context, String drinkName, String drinkType, String drinkVolume, String drinkVolumeType, String drinkQuantity, String drinkUnits, String drinkABV, String drinkVolumeTypePos, String drinkTypePos) {
        String favouriteDrinks = SharedPreferencesWrapper.getFromPrefs(context, "favourite_drinks", "NO_FAVOURITE_DRINKS");
        if (favouriteDrinks.equals("NO_FAVOURITE_DRINKS")) {
            favouriteDrinks = drinkName + "^" + drinkType + "^" + drinkVolume + "^" + drinkVolumeType + "^" + drinkQuantity + "^" + drinkUnits + "^" + drinkABV + "^" + drinkVolumeTypePos + "^" + drinkTypePos + ";";
        } else {
            favouriteDrinks = favouriteDrinks + drinkName + "^" + drinkType + "^" + drinkVolume + "^" + drinkVolumeType + "^" + drinkQuantity + "^" + drinkUnits + "^" + drinkABV + "^" + drinkVolumeTypePos + "^" + drinkTypePos + ";";
        }
        SharedPreferencesWrapper.saveToPrefs(context, "favourite_drinks", favouriteDrinks);
    }

    private static List<String[]> createFavouriteDrinksFromStorage(Context context) {
        String favouriteDrinks = SharedPreferencesWrapper.getFromPrefs(context, "favourite_drinks", "No Favourite Drinks");
        if (!favouriteDrinks.equals("No Favourite Drinks")) {
            String[] temp1 = favouriteDrinks.split(";");
            List<String[]> favouriteDrinksArray = new ArrayList<String[]>();
            for (String string : temp1) {
                String[] temp2 = string.split("\\^");
                favouriteDrinksArray.add(temp2);
            }
            return favouriteDrinksArray;
        } else {
            List<String[]> noDrinks = new ArrayList<String[]>();
            String[] noDrinksStringArray = new String[1];
            noDrinksStringArray[0] = "No Favourite Drinks";
            noDrinks.add(noDrinksStringArray);
            return noDrinks;
        }
    }

    public static List<String> getFavouriteDrinkTitles(Context context) {
        List<String[]> favouriteDrinksArray = createFavouriteDrinksFromStorage(context);
        List<String> favouriteDrinkTitles = new ArrayList<String>();
        for (String[] stringArray : favouriteDrinksArray) {
            favouriteDrinkTitles.add(stringArray[0]);
        }
        return favouriteDrinkTitles;
    }

    public static String[] getFavouriteDrink(Context context, int pos) {
        List<String[]> favouriteDrinksArray = createFavouriteDrinksFromStorage(context);
        return favouriteDrinksArray.get(pos);
    }
}




Java Source Code List

scamell.michael.amulet.AboutDialogFragment.java
scamell.michael.amulet.AccountDetailsFragment.java
scamell.michael.amulet.ChangePasswordDialogFragment.java
scamell.michael.amulet.CoolveticaTextView.java
scamell.michael.amulet.DateAndTime.java
scamell.michael.amulet.DrinkDiaryEntries.java
scamell.michael.amulet.DrinkDiaryEntryAdapter.java
scamell.michael.amulet.DrinkDiaryEntry.java
scamell.michael.amulet.DrinkDiaryFavouriteDrinksDialogFragment.java
scamell.michael.amulet.DrinkDiaryFragment.java
scamell.michael.amulet.ExampleDrinksDialogFragment.java
scamell.michael.amulet.FavouriteDrinkUtility.java
scamell.michael.amulet.HomeFragment.java
scamell.michael.amulet.InspectionTaskActivity.java
scamell.michael.amulet.InspectionTaskInstructions1Fragment.java
scamell.michael.amulet.InspectionTaskInstructions2Fragment.java
scamell.michael.amulet.LastTaskInstructionFragment.java
scamell.michael.amulet.LoginActivity.java
scamell.michael.amulet.LogoutDialogFragment.java
scamell.michael.amulet.MainActivity.java
scamell.michael.amulet.OnPostHttpData.java
scamell.michael.amulet.OnRetrieveHttpData.java
scamell.michael.amulet.PostHTTPDataAsync.java
scamell.michael.amulet.RegisterActivity.java
scamell.michael.amulet.ResumeTaskDialogFragment.java
scamell.michael.amulet.RetrieveHTTPDataAsync.java
scamell.michael.amulet.RetrieveHTTPData.java
scamell.michael.amulet.RetrieveTaskDataFromServer.java
scamell.michael.amulet.SaveDrinkDiaryUtility.java
scamell.michael.amulet.SendDrinkDiaryEntriesToServer.java
scamell.michael.amulet.SendDrinkDiaryEntryToServer.java
scamell.michael.amulet.SendTaskEntriesToServer.java
scamell.michael.amulet.SendTaskEntryToServer.java
scamell.michael.amulet.SequenceTaskActivity.java
scamell.michael.amulet.SequenceTaskInstruction1Fragment.java
scamell.michael.amulet.SequenceTaskInstruction2Fragment.java
scamell.michael.amulet.SequenceTaskInstruction3Fragment.java
scamell.michael.amulet.SharedPreferencesWrapper.java
scamell.michael.amulet.Sound.java
scamell.michael.amulet.TaskEntries.java
scamell.michael.amulet.TaskEntry.java
scamell.michael.amulet.TaskFinishFragment.java
scamell.michael.amulet.TaskInstructionsActivity.java
scamell.michael.amulet.TaskStartCountdownFragment.java
scamell.michael.amulet.TasksFirstStartWelcomeFragment.java
scamell.michael.amulet.TasksMenuFragment.java
scamell.michael.amulet.UnitCalculatorFavouriteDrinksDialogFragment.java
scamell.michael.amulet.UnitCalculatorFragment.java
scamell.michael.amulet.UnitCalculator.java