/**
   * Prepare this editor using the given {@link DataKind} for defining structure and {@link
   * ValuesDelta} describing the content to edit.
   */
  @Override
  public void setValues(
      DataKind kind,
      ValuesDelta entry,
      RawContactDelta state,
      boolean readOnly,
      ViewIdGenerator vig) {
    mKind = kind;
    mEntry = entry;
    mState = state;
    mReadOnly = readOnly;
    mViewIdGenerator = vig;
    setId(vig.getId(state, kind, entry, ViewIdGenerator.NO_VIEW_INDEX));

    if (!entry.isVisible()) {
      // Hide ourselves entirely if deleted
      setVisibility(View.GONE);
      return;
    }
    setVisibility(View.VISIBLE);

    // Display label selector if multiple types available
    final boolean hasTypes = RawContactModifier.hasEditTypes(kind);
    setupLabelButton(hasTypes);
    mLabel.setEnabled(!readOnly && isEnabled());
    if (hasTypes) {
      mType = RawContactModifier.getCurrentType(entry, kind);
      rebuildLabel();
    }
  }
  @Override
  public void onFieldChanged(String column, String value) {
    if (!isFieldChanged(column, value)) {
      return;
    }

    // Field changes are saved directly
    saveValue(column, value);

    // Notify listener if applicable
    notifyEditorListener();

    rebuildLabel();
  }
  protected void onTypeSelectionChange(int position) {
    EditType selected = mEditTypeAdapter.getItem(position);
    // See if the selection has in fact changed
    if (mEditTypeAdapter.hasCustomSelection() && selected == CUSTOM_SELECTION) {
      return;
    }

    if (mType == selected && mType.customColumn == null) {
      return;
    }

    if (selected.customColumn != null) {
      showDialog(DIALOG_ID_CUSTOM);
    } else {
      // User picked type, and we're sure it's ok to actually write the entry.
      mType = selected;
      mEntry.put(mKind.typeColumn, mType.rawValue);
      rebuildLabel();
      requestFocusForFirstEditField();
      onLabelRebuilt();
    }
  }