io.realm
Un OrderedRealmCollectionSnapshot es un tipo especial de OrderedRealmCollection . Puede ser creado llamando a OrderedRealmCollection.createSnapshot() . A diferencia de RealmResults y RealmList , su tamaño y orden de elementos nunca cambiarán después de la creación.
OrderedRealmCollectionSnapshot es útil al realizar cambios que pueden afectar el tamaño o el orden de la colección en bucles simples. Por ejemplo:
final RealmResults<Dog> dogs = realm.where(Dog.class).findAll(); final OrderedRealmCollectionSnapshot<Dog> snapshot = dogs.createSnapshot(); final int dogsCount = snapshot.size(); // dogs.size() == snapshot.size() == 10 realm.executeTransaction(new Realm.Transaction() { / public void execute(Realm realm) { for (int i = 0; i < dogsCount; i++) { // This won't work since RealmResults is always up-to-date, its size gets decreased by 1 after every loop. An // IndexOutOfBoundsException will be thrown after 5 loops. // dogs.deleteFromRealm(i); snapshot.deleteFromRealm(i); // Deletion on OrderedRealmCollectionSnapshot won't change the size of it. } } });
Resumen del método
Modificador y Tipo | Método y descripción |
|---|---|
Creates a snapshot from this OrderedRealmCollection . | |
public booleano | Esto borra todos los objetos en la colección del Realm subyacente. |
public booleano | Deletes the first object from the Realm. |
public void | Deletes the object at the given index from the Realm. |
public booleano | Deletes the last object from the Realm. |
public OrderedRealmCollection | freeze () |
public booleano | isFrozen () |
public booleano | isLoaded () Checks if a collection has finished loading its data yet. |
public booleano | load () Blocks the collection until all data are available. |
public int | size () Devuelve el número de elementos en este resultado de consulta. |
public RealmResults | Not supported by OrderedRealmCollectionSnapshot . |
public RealmResults | |
public RealmResults | Not supported by OrderedRealmCollectionSnapshot . |
public RealmResults | Not supported by OrderedRealmCollectionSnapshot . |
public RealmQuery | where () Not supported by OrderedRealmCollectionSnapshot . |
Inherited Methods
Métodos heredados de la clase java.lang.Object:
getClass,hashCode,equals,clone,toString,notify,notifyAll,wait,wait,wait,finalizeMethods inherited from class java.util.AbstractCollection :
iterator,size,isEmpty,contains,toArray,toArray,add,remove,containsAll,addAll,removeAll,retainAll,clear,toStringMethods inherited from class java.util.AbstractList :
add,get,set,add,remove,indexOf,lastIndexOf,clear,addAll,iterator,listIterator,listIterator,subList,equals,hashCode,removeRangeMethods inherited from class io.realm.OrderedRealmCollectionImpl:
isValid,isManaged,contains,get,first,first,last,last,deleteFromRealm,deleteAllFromRealm,iterator,listIterator,listIterator,sort,sort,sort,sort,size,min,minDate,max,maxDate,sum,average,remove,remove,removeAll,set,retainAll,deleteLastFromRealm,deleteFirstFromRealm,clear,add,add,addAll,addAll,createSnapshot,getRealm,getCollectionOperator
Detalle del método
createSnapshot
public OrderedRealmCollectionSnapshot createSnapshot () |
|---|
Creates a snapshot from this OrderedRealmCollection . Devuelve the snapshot of this collection. Anulaciones
|
deleteAllFromRealm
public boolean deleteAllFromRealm () |
|---|
This deletes all objects in the collection from the underlying Realm. All objects in the collection snapshot will become invalid. Devuelve
Throws
Anulaciones
|
deleteFirstFromRealm
public boolean deleteFirstFromRealm () |
|---|
Deletes the first object from the Realm. The first object will become invalid. Devuelve
Throws
Anulaciones
|
deleteFromRealm
Deletes the object at the given index from the Realm. The object at the given index will become invalid. Just returns if the object is invalid already. Parámetros
Throws
Anulaciones
|
deleteLastFromRealm
public boolean deleteLastFromRealm () |
|---|
Deletes the last object from the Realm. The last object will become invalid. Devuelve
Throws
Anulaciones
|
freeze
public OrderedRealmCollection freeze () |
|---|
isFrozen
public boolean isFrozen () |
|---|
isLoaded
public boolean isLoaded () |
|---|
Checks if a collection has finished loading its data yet. Devuelve
|
cargar
public boolean load () |
|---|
Blocks the collection until all data are available. Devuelve
|
Tamaño
public int size () |
|---|
Devuelve el número de elementos en este resultado de consulta. Devuelve the number of elements in this query result. Anulaciones
|
sort
Not supported by OrderedRealmCollectionSnapshot . Use 'sort()' on the original OrderedRealmCollection instead. Devuelve se creará y devolverá un nuevo RealmResults ordenado. La colección original permanece sin cambios. Throws Anulaciones
|
Not supported by OrderedRealmCollectionSnapshot . Use 'sort()' on the original OrderedRealmCollection instead. Devuelve se creará y devolverá un nuevo RealmResults ordenado. La colección original permanece sin cambios. Throws Anulaciones
|
Not supported by OrderedRealmCollectionSnapshot . Use 'sort()' on the original OrderedRealmCollection instead. Devuelve se creará y devolverá un nuevo RealmResults ordenado. La colección original permanece sin cambios. Throws Anulaciones
|
Not supported by OrderedRealmCollectionSnapshot . Use 'sort()' on the original OrderedRealmCollection instead. Devuelve se creará y devolverá un nuevo RealmResults ordenado. La colección original permanece sin cambios. Throws Anulaciones
|
dónde
public RealmQuery where () |
|---|
Not supported by OrderedRealmCollectionSnapshot . Use 'where()' on the original OrderedRealmCollection instead. Devuelve un objeto de RealmQuery. Throws |