package net.tasksnow.view.task;
import android.content.Context;
import android.graphics.drawable.Drawable;
import net.tasksnow.R;
import java.util.HashMap;
/**
* @author D056943
* @since 13:41:49 - 19.12.2012
* @project cFoldersDemo
*/
public class ActionMapper {
// ===========================================================
// Constants
// ===========================================================
public static final int ACTION_NOACTION = 0;//No Action
public static final int ACTION_CALL = 1; // Action for doing a Call
public static final int ACTION_LOCATION = 2; //Action for Navigating to a Location
public static final int ACTION_MESSAGE = 3; //Action for writing a new Message
public static final int ACTION_URL = 4;//Action for writing a new Message
public static final int ACTION_TIMER = 5;//Action for setting a Timer
// ===========================================================
// Fields
// ===========================================================
private static HashMap<Integer, Integer> actionMap = generateActionMap();
private static HashMap<Integer, Integer> actionImageMap = generateActionImageMap();
// ===========================================================
// Constructors
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
private static HashMap<Integer, Integer> generateActionImageMap() {
actionImageMap = new HashMap<Integer, Integer>();
actionImageMap.put(ActionMapper.ACTION_CALL, R.drawable.ic_action_call);
actionImageMap.put(ActionMapper.ACTION_LOCATION, R.drawable.ic_action_location);
actionImageMap.put(ActionMapper.ACTION_MESSAGE, R.drawable.ic_action_message);
actionImageMap.put(ActionMapper.ACTION_URL, R.drawable.ic_action_url);
actionImageMap.put(ActionMapper.ACTION_TIMER, R.drawable.ic_action_timer);
actionImageMap.put(ActionMapper.ACTION_NOACTION, null);
return actionImageMap;
}
private static HashMap<Integer, Integer> generateActionMap() {
actionMap = new HashMap<Integer, Integer>();
actionMap.put(ActionMapper.ACTION_CALL, R.string.action_call);
actionMap.put(ActionMapper.ACTION_LOCATION, R.string.action_location);
actionMap.put(ActionMapper.ACTION_MESSAGE, R.string.action_message);
actionMap.put(ActionMapper.ACTION_URL, R.string.action_url);
actionMap.put(ActionMapper.ACTION_TIMER, R.string.action_timer);
actionMap.put(ActionMapper.ACTION_NOACTION, R.string.action_noaction);
return actionMap;
}
public static HashMap<Integer, Integer> getActionMap() {
return actionMap;
}
public static Drawable getActionImage(int key, Context context) {
Integer imgRes = actionImageMap.get(key);
if (imgRes == null || imgRes == -1) {
//TODO Unknown Image strRes = R.string.action_unknown;
return null;
}
if (context != null && context.getResources() != null)
return context.getResources().getDrawable(imgRes);
else
return null;
}
public static String getActionName(int key, Context context) {
Integer strRes = actionMap.get(key);
if (strRes == null) {
strRes = R.string.action_unknown;
}
if (context != null && context.getResources() != null)
return context.getResources().getString(strRes);
else
return "An unknown Error occurred";
}
}