/** 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 (!mKind.isList) { if (hasEntries) { // we might have no visible entries. check that, too for (ValuesDelta entry : mState.getMimeEntries(mKind.mimeType)) { if (!entry.isVisible()) { hasEntries = false; break; } } } if (!hasEntries) { EntityModifier.insertChild(mState, mKind); hasEntries = true; } } if (hasEntries) { int entryIndex = 0; for (ValuesDelta entry : mState.getMimeEntries(mKind.mimeType)) { // Skip entries that aren't visible if (!entry.isVisible()) continue; final GenericEditorView editor = (GenericEditorView) mInflater.inflate(R.layout.item_generic_editor, mEditors, false); editor.setValues(mKind, entry, mState, mReadOnly, mViewIdGenerator); // older versions of android had lists where we now have a single value // in these cases we should show the remove button for all but the first value // to ensure that nothing is removed editor.mDelete.setVisibility( (mKind.isList || (entryIndex != 0)) ? View.VISIBLE : View.GONE); editor.setEditorListener(this); mEditors.addView(editor); entryIndex++; } } }
/** Find {@link RawContacts#_ID} of the requested {@link EntityDelta}. */ public Long getRawContactId(int index) { if (index >= 0 && index < this.size()) { final EntityDelta delta = this.get(index); final ValuesDelta values = delta.getValues(); if (values.isVisible()) { return values.getAsLong(RawContacts._ID); } } return null; }