blob: 92a1082719b69b47466a598daa41c75f40fb8fb8 [file] [log] [blame]
package com.google.lizlooney.shoppinglist;
import android.content.Context;
/**
* Enum for the different display modes.
*
* @author lizlooney@gmail.com (Liz Looney)
*/
public enum DisplayMode {
/**
* When I am planning what I need, all items are displayed. Items are sorted by category and the
* category column is displayed.
*/
PLANNING,
/**
* When I am shopping, items with state DONT_NEED are omitted. Items are sorted by aisle and the
* aisle column is displayed.
*/
SHOPPING;
public static DisplayMode fromString(Context context, String s) {
if (s.equals(context.getString(R.string.DisplayModePlanning))) {
return DisplayMode.PLANNING;
}
if (s.equals(context.getString(R.string.DisplayModeShopping))) {
return DisplayMode.SHOPPING;
}
throw new IllegalArgumentException();
}
public static String toString(Context context, DisplayMode displayMode) {
switch (displayMode) {
default:
case PLANNING:
return context.getString(R.string.DisplayModePlanning);
case SHOPPING:
return context.getString(R.string.DisplayModeShopping);
}
}
public static String[] getStrings(Context context) {
return new String[] {
DisplayMode.toString(context, DisplayMode.PLANNING),
DisplayMode.toString(context, DisplayMode.SHOPPING)
};
}
}