Java Code Examples for android.content.Entity

The following are top voted examples for showing how to use android.content.Entity. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Prevail   File: CursorEntityIterator.java   View source code 6 votes vote down vote up
/**
 * Returns the next object in the iteration, i.e. returns the element in front of the iterator and advances the iterator by one position.
 *
 * @return the next object.
 * @throws java.util.NoSuchElementException if there are no more elements.
 * @see android.content.EntityIterator#hasNext()
 */
@Override
public final Entity next() {
  if (mIsClosed) {
    throw new IllegalStateException("calling next() when the iterator is closed");
  }
  if (!hasNext()) {
    throw new IllegalStateException("you may only call next() if hasNext() is true");
  }

  try {
    return getEntityAndIncrementCursor(mCursor);
  } catch (RemoteException e) {
    throw new RuntimeException("caught a remote exception, this process will die soon", e);
  }
}
 
Example 2
Project: silent-contacts-android   File: RawContact.java   View source code 5 votes vote down vote up
public static RawContact createFrom(Entity entity) {
    final ContentValues values = entity.getEntityValues();
    final ArrayList<Entity.NamedContentValues> subValues = entity.getSubValues();

    RawContact rawContact = new RawContact(null, values);
    for (Entity.NamedContentValues subValue : subValues) {
        rawContact.addNamedDataItemValues(subValue.uri, subValue.values);
    }
    return rawContact;
}
 
Example 3
Project: silent-contacts-android   File: RawContactDeltaList.java   View source code 5 votes vote down vote up
/**
 * Create an {@link RawContactDeltaList} that contains the entities of the Iterator as before
 * values.  This function can be passed an iterator of Entity objects or an iterator of
 * RawContact objects.
 */
public static RawContactDeltaList fromIterator(Iterator<?> iterator) {
    final RawContactDeltaList state = new RawContactDeltaList();
    // Perform background query to pull contact details
    while (iterator.hasNext()) {
        // Read all contacts into local deltas to prepare for edits
        Object nextObject = iterator.next();
        final RawContact before = nextObject instanceof Entity
                ? RawContact.createFrom((Entity) nextObject)
                : (RawContact) nextObject;
        final RawContactDelta rawContactDelta = RawContactDelta.fromBefore(before);
        state.add(rawContactDelta);
    }
    return state;
}
 
Example 4
Project: feeds   File: PersistentEntity.java   View source code 4 votes vote down vote up
protected PersistentEntity(Entity instance) {
    this(instance.getEntityValues());
}
 
Example 5
Project: feeds   File: PersistentEntity.java   View source code 4 votes vote down vote up
protected PersistentEntity(ContentValues contentValues) {
    INSTANCE = new Entity(new ContentValues());
}
 
Example 6
Project: Prevail   File: CursorEntityIterator.java   View source code 2 votes vote down vote up
/**
 * Returns the entity that the cursor is currently pointing to. This must take care to advance the cursor past this entity. This will never be called if the cursor is at the end.
 *
 * @param cursor the cursor that contains the entity rows
 *
 * @return the entity that the cursor is currently pointing to
 * @throws android.os.RemoteException if a RemoteException is caught while attempting to build the Entity
 */
public abstract Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException;