/** Rebuild the editor to match our underlying {@link #mEntityDeltaList} object. */ private void bindEditor() { if (mEntityDeltaList == null) { throw new IllegalStateException(); } // If no valid raw contact (to insert the data) was found, we won't have an editable // account type to use. In this case, display an error message and hide the "OK" button. if (mIsReadOnly) { mReadOnlyWarningView.setText(getString(R.string.contact_read_only)); mReadOnlyWarningView.setVisibility(View.VISIBLE); mEditorContainerView.setVisibility(View.GONE); findViewById(R.id.btn_done).setVisibility(View.GONE); // Nothing more to be done, just show the UI showDialogContent(); return; } // Otherwise display an editor that allows the user to add the data to this raw contact. for (DataKind kind : mEditableAccountType.getSortedDataKinds()) { // Skip kind that are not editable if (!kind.editable) continue; if (mMimetype.equals(kind.mimeType)) { for (ValuesDelta valuesDelta : mRawContactDelta.getMimeEntries(mMimetype)) { // Skip entries that aren't visible if (!valuesDelta.isVisible()) continue; if (valuesDelta.isInsert()) { inflateEditorView(kind, valuesDelta, mRawContactDelta); return; } } } } }
@Override protected void setUp() throws Exception { super.setUp(); mMockContext = new ContactsMockContext(getContext()); mContactsProvider = mMockContext.getContactsProvider(); InjectedServices services = new InjectedServices(); AccountType accountType = new BaseAccountType() { @Override public boolean areContactsWritable() { return false; } }; accountType.accountType = "mockAccountType"; AccountWithDataSet account = new AccountWithDataSet("mockAccountName", "mockAccountType", null); mMockContext.setMockAccountTypeManager( new MockAccountTypeManager( new AccountType[] {accountType}, new AccountWithDataSet[] {account})); }