/** Build editors for all current {@link #mState} rows. */ public void rebuildFromState() { // Remove any existing editors mEditors.removeAllViews(); // Check if we are displaying anything here boolean hasEntries = mState.hasMimeEntries(mKind.mimeType); if (hasEntries) { for (ValuesDelta entry : mState.getMimeEntries(mKind.mimeType)) { // Skip entries that aren't visible if (!entry.isVisible()) continue; if (isEmptyNoop(entry)) continue; createEditorView(entry); } } }
public void addItem() { ValuesDelta values = null; // If this is a list, we can freely add. If not, only allow adding the first. if (mKind.typeOverallMax == 1) { if (getEditorCount() == 1) { return; } // If we already have an item, just make it visible ArrayList<ValuesDelta> entries = mState.getMimeEntries(mKind.mimeType); if (entries != null && entries.size() > 0) { values = entries.get(0); } } // Insert a new child, create its view and set its focus if (values == null) { values = RawContactModifier.insertChild(mState, mKind); } final View newField = createEditorView(values); if (newField instanceof Editor) { postWhenWindowFocused( new Runnable() { @Override public void run() { newField.requestFocus(); ((Editor) newField).editNewlyAddedField(); } }); } // Hide the "add field" footer because there is now a blank field. mAddFieldFooter.setVisibility(View.GONE); // Ensure we are visible updateSectionVisible(); }