Class HealthChangeBatch
java.lang.Object
com.codename1.health.HealthChangeBatch
A set of changes since the last time a subscription was drained.
Delivered to
HealthChangeListener in the foreground and to
HealthBackgroundListener after a background relaunch.-
Constructor Summary
ConstructorsConstructorDescriptionHealthChangeBatch(String subscriptionId, List<HealthDataType> types, List<HealthSample> added, List<String> deletedSampleIds, boolean resyncRequired, HealthAnchor anchor, long deadlineMillis, boolean more) Creates a batch. -
Method Summary
Modifier and TypeMethodDescriptiongetAdded()Samples added or updated since the last drain.The cursor after this batch.longRoughly how much wall-clock time the listener has before the OS may suspend the process, in milliseconds.Identifiers of samples removed since the last drain.The subscription this batch belongs to.getTypes()The types covered by this batch.booleanhasMore()truewhen more changes were available thanSubscriptionRequest.getMaxSamplesPerBatch()allowed.booleanisEmpty()truewhen nothing changed and no resync is needed.booleantruewhen the platform cursor was lost and incremental delivery cannot continue -- a Health Connect change token older than 30 days, or an iOS anchor rejected after a restore from backup.toString()Returns a string representation of the object.
-
Constructor Details
-
HealthChangeBatch
public HealthChangeBatch(String subscriptionId, List<HealthDataType> types, List<HealthSample> added, List<String> deletedSampleIds, boolean resyncRequired, HealthAnchor anchor, long deadlineMillis, boolean more) Creates a batch. Called byHealthStore; the lists are copied defensively.
-
-
Method Details
-
getSubscriptionId
The subscription this batch belongs to. -
getTypes
The types covered by this batch. -
getAdded
Samples added or updated since the last drain. Empty when the subscription setSubscriptionRequest.setDeliverSamples(boolean)to false, and empty whenisResyncRequired(). -
getDeletedSampleIds
-
isResyncRequired
public boolean isResyncRequired()truewhen the platform cursor was lost and incremental delivery cannot continue -- a Health Connect change token older than 30 days, or an iOS anchor rejected after a restore from backup.getAdded()is empty in that case. The app must do a full time-range read to catch up; nothing else will deliver the missed data. -
getAnchor
The cursor after this batch. Persisted byHealthStoreautomatically; exposed for apps that checkpoint against their own server -- seeHealthAnchor. -
getDeadlineMillis
public long getDeadlineMillis()Roughly how much wall-clock time the listener has before the OS may suspend the process, in milliseconds. About 5000 on an iOS background relaunch;
Long.MAX_VALUEin the foreground.Do cheap bookkeeping inside a background delivery -- accumulate a counter, stash an identifier -- and leave network calls for the next foreground.
-
hasMore
public boolean hasMore()truewhen more changes were available thanSubscriptionRequest.getMaxSamplesPerBatch()allowed. The remainder arrives in the next delivery, or immediately onHealthStore.drainChanges(). -
isEmpty
public boolean isEmpty()truewhen nothing changed and no resync is needed. -
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
-