public int getMimeEntriesCount(String mimeType, boolean onlyVisible) { final ArrayList<ValuesDelta> mimeEntries = getMimeEntries(mimeType); if (mimeEntries == null) return 0; int count = 0; for (ValuesDelta child : mimeEntries) { // Skip deleted items when requesting only visible if (onlyVisible && !child.isVisible()) continue; count++; } return count; }
public boolean isVisible() { return getValues().isVisible(); }
/** * Find {@link RawContacts#_ID} of the requested {@link RawContactDelta}. */ public Long getRawContactId(int index) { if (index >= 0 && index < this.size()) { final RawContactDelta delta = this.get(index); final ValuesDelta values = delta.getValues(); if (values.isVisible()) { return values.getAsLong(RawContacts._ID); } } return null; }
/** * Count up the frequency that each {@link EditType} appears in the given * {@link RawContactDelta}. The returned {@link SparseIntArray} maps from * {@link EditType#rawValue} to counts, with the total overall count stored * as {@link #FREQUENCY_TOTAL}. */ private static SparseIntArray getTypeFrequencies(RawContactDelta state, DataKind kind) { final SparseIntArray typeCount = new SparseIntArray(); // Find all entries for this kind, bailing early if none found final List<ValuesDelta> mimeEntries = state.getMimeEntries(kind.mimeType); if (mimeEntries == null) return typeCount; int totalCount = 0; for (ValuesDelta entry : mimeEntries) { // Only count visible entries if (!entry.isVisible()) continue; totalCount++; final EditType type = getCurrentType(entry, kind); if (type != null) { final int count = typeCount.get(type.rawValue); typeCount.put(type.rawValue, count + 1); } } typeCount.put(FREQUENCY_TOTAL, totalCount); return typeCount; }