/**
   * 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;
  }
  /**
   * Helper for showing and hiding {@link #mFooterDisambig}, which will correctly manage {@link
   * #mArrowDown} as needed.
   */
  private void setResolveVisible(boolean visible, CheckableImageView actionView) {
    // Show or hide the resolve list if needed
    boolean visibleNow = mFooterDisambig.getVisibility() == View.VISIBLE;

    if (mLastAction != null) mLastAction.setChecked(false);
    if (actionView != null) actionView.setChecked(true);
    mLastAction = actionView;

    // Bail early if already in desired state
    if (visible == visibleNow) return;

    mFooter.setVisibility(visible ? View.GONE : View.VISIBLE);
    mFooterDisambig.setVisibility(visible ? View.VISIBLE : View.GONE);

    if (visible) {
      // If showing list, then hide and save state of down arrow
      mWasDownArrow = mWasDownArrow || (mArrowDown.getVisibility() == View.VISIBLE);
      mArrowDown.setVisibility(View.INVISIBLE);
    } else {
      // If hiding list, restore any down arrow state
      mArrowDown.setVisibility(mWasDownArrow ? View.VISIBLE : View.INVISIBLE);
    }
  }