/** * Inflate the in-track view for the action of the given MIME-type. Will use the icon provided by * the {@link DataKind}. */ private View inflateAction(String mimeType) { final CheckableImageView view = (CheckableImageView) obtainView(); boolean isActionSet = false; // Add direct intent if single child, otherwise flag for multiple ActionList children = mActions.get(mimeType); Action firstInfo = children.get(0); if (children.size() == 1) { view.setTag(firstInfo); } else { for (Action action : children) { if (action.isPrimary()) { view.setTag(action); isActionSet = true; break; } } if (!isActionSet) { view.setTag(children); } } // Set icon and listen for clicks final CharSequence descrip = mResolveCache.getDescription(firstInfo); final Drawable icon = mResolveCache.getIcon(firstInfo); view.setChecked(false); view.setContentDescription(descrip); view.setImageDrawable(icon); view.setOnClickListener(this); return view; }
public void setActionListener(ActionListener listener) { ActionList actionList = getActionList(); int nActions = actionList.size(); for (int n = 0; n < nActions; n++) { Action action = actionList.getAction(n); action.setActionListener(listener); } }
public Action getAction(String actionName) { ActionList actionList = getActionList(); int nActions = actionList.size(); for (int n = 0; n < nActions; n++) { Action action = actionList.getAction(n); String name = action.getName(); if (name == null) continue; if (name.equals(actionName) == true) return action; } return null; }
void updateActionList(TreeNode parentNode, Service service) { ActionList actionList = service.getActionList(); int nActions = actionList.size(); for (int n = 0; n < nActions; n++) { Action action = actionList.getAction(n); String actionName = action.getName(); TreeNode actionNode = new TreeNode(actionName); actionNode.setUserData(action); parentNode.add(actionNode); updateArgumentList(actionNode, action); } }
/** * Adds a list of {@link Action}s. * * @param actionList the actions to add */ public void addActions(ActionList actionList) { int actions = actionList.size(); for (int i = 0; i < actions; i++) { addAction(actionList.get(i)); } }