Class HKWorkoutBuilder

  • All Implemented Interfaces:
    NSObject

    public class HKWorkoutBuilder
    extends NSObject
    HKWorkoutBuilder An HKWorkoutBuilder is used to incrementally create new workouts in the HealthKit database. Samples, events, and metadata may be added to a builder either during a live workout session or to create a workout that occurred in the past. Calling finishWorkoutWithCompletion: will create a new workout with samples, events, and metadata that have been provided.
    • Constructor Detail

      • HKWorkoutBuilder

        protected HKWorkoutBuilder​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • addMetadataCompletion

        public void addMetadataCompletion​(NSDictionary<java.lang.String,​?> metadata,
                                          HKWorkoutBuilder.Block_addMetadataCompletion completion)
        addMetadata:completion: Adds new metadata to the builder instance. This method can be called more than once; each time the newly provided metadata will be merged with previously added metadata in the same manner as -[NSMutableDictionary addEntriesFromDictionary:]. This operation is performed asynchronously and the completion will be executed on an arbitrary background queue.
        Parameters:
        metadata - The metadata to add to the workout.
        completion - Block to be called when the addition of metadata to the builder is complete. If success is YES, the metadata has been added to the builder successfully. If success is NO, error will be non-null and will contain the error encountered during the insertion operation. When an error occurs, the builder's metadata property will remain unchanged.
      • addSamplesCompletion

        public void addSamplesCompletion​(NSArray<? extends HKSample> samples,
                                         HKWorkoutBuilder.Block_addSamplesCompletion completion)
        addSamples:completion: Adds new samples to the builder instance. This method can be called multiple times to add samples incrementally to the builder. The samples will be saved to the database if they have not already been saved. The constraints of -[HKHealthStore saveObject:withCompletion:] apply to this method as well. The start date of the samples must be later than the start date of the receiver. It is an error to call this method after finishWorkoutWithCompletion: has been called. This operation is performed asynchronously and the completion will be executed on an arbitrary background queue.
        Parameters:
        samples - The samples to add to the workout.
        completion - Block to be called when the insertion is complete. If success is YES, the samples were added to the builder successfully. If success is NO, error will be non-nil and contain the error encountered while adding the new samples.
      • addWorkoutEventsCompletion

        public void addWorkoutEventsCompletion​(NSArray<? extends HKWorkoutEvent> workoutEvents,
                                               HKWorkoutBuilder.Block_addWorkoutEventsCompletion completion)
        addWorkoutEvents:completion: Adds new workout events to the builder instance. This method can be called many times to add workout events incrementally to the builder. It is an error to call this method after finishWorkoutWithCompletion: has been called. This operation is performed asynchronously and the completion will be executed on an arbitrary background queue.
        Parameters:
        workoutEvents - The events to add to the builder.
        completion - Block to be called when the addition of events to the builder is complete. If success is YES, the events were added to the builder successfully. If success is NO, error will be non-null and will contain the error encountered during the insertion operation.
      • allocWithZone

        public static java.lang.Object allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(java.lang.String key)
      • beginCollectionWithStartDateCompletion

        public void beginCollectionWithStartDateCompletion​(NSDate startDate,
                                                           HKWorkoutBuilder.Block_beginCollectionWithStartDateCompletion completion)
        beginCollectionWithStartDate:error: Sets the workout start date and activates the workout builder. Calling this method is required before any samples, events or metadata can be added to the builder.
        Parameters:
        startDate - The start date of the workout.
        completion - Called once data collection has started or has failed to start.
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(java.lang.Object aTarget,
                                                                                 org.moe.natj.objc.SEL aSelector,
                                                                                 java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        public static org.moe.natj.objc.Class classForKeyedUnarchiver()
      • debugDescription_static

        public static java.lang.String debugDescription_static()
      • description_static

        public static java.lang.String description_static()
      • device

        public HKDevice device()
        [@property] device The HKDevice to be associated with the workout.
      • discardWorkout

        public void discardWorkout()
        discardWorkout Finishes building the workout and discards ther result instead of saving it. Samples that were added to the workout will not be deleted. Adding samples, events, and metadata to the receiver after discardWorkout has been called is an error.
      • elapsedTimeAtDate

        public double elapsedTimeAtDate​(NSDate date)
        elapsedTimeAtDate: The elapsed duration of the workout evaluated at the specified date. The duration does not include periods when the workout was paused, which are the intervals between pause and resume events.
      • endCollectionWithEndDateCompletion

        public void endCollectionWithEndDateCompletion​(NSDate endDate,
                                                       HKWorkoutBuilder.Block_endCollectionWithEndDateCompletion completion)
        endCollectionWithEndDate:error: Sets the workout end date and deactivates the workout builer. Calling this method is required before you finish a workout builder.
        Parameters:
        endDate - The end date of the workout.
        completion - Called once data collection has stopped or has failed to stop.
      • endDate

        public NSDate endDate()
        [@property] endDate The end date for the workout, as provided by endCollectionWithEndDate:completion:
      • finishWorkoutWithCompletion

        public void finishWorkoutWithCompletion​(HKWorkoutBuilder.Block_finishWorkoutWithCompletion completion)
        finishWorkoutWithCompletion: Creates and saves an HKWorkout using samples and events that have been added to workout previously.
        Parameters:
        completion - Block to be called after the HKWorkout object has been created and saved. If success is NO, then error will be the error encountered during the operation.
      • hash_static

        public static long hash_static()
      • initWithHealthStoreConfigurationDevice

        public HKWorkoutBuilder initWithHealthStoreConfigurationDevice​(HKHealthStore healthStore,
                                                                       HKWorkoutConfiguration configuration,
                                                                       HKDevice device)
        initWithHealthStore:configuration:device: The designated initializer to create an HKWorkoutBuilder. Creates a new HKWorkoutBuilder unconnected to any HKWorkoutSession or any sources of data.
        Parameters:
        healthStore - Specifies the HKHealthStore object to use for building the workout. The store is retained until the builder is finished and a workout has been saved or discarded.
        configuration - The workout configuration to be used.
        device - The HKDevice to attach to the resulting HKWorkout.
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
      • keyPathsForValuesAffectingValueForKey

        public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(java.lang.String key)
      • metadata

        public NSDictionary<java.lang.String,​?> metadata()
        [@property] metadata The metadata that will be used when the workout is finished.
      • new_objc

        public static java.lang.Object new_objc()
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
      • seriesBuilderForType

        public HKSeriesBuilder seriesBuilderForType​(HKSeriesType seriesType)
        seriesBuilderForType: Retrieves the associated series builder for the specified type. Retrieves, and creates if it does not already exist, the series builder for the specified type. The series constructed with the returned builder will be associated with the workout when it is finished.
        Parameters:
        seriesType - The series type for which the builder should be retrieved.
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • startDate

        public NSDate startDate()
        [@property] startDate The start date for the workout, as provided by beginCollectionWithStartDate:completion:
      • statisticsForType

        public HKStatistics statisticsForType​(HKQuantityType quantityType)
        statisticsForType: Returns an HKStatistics object containing the statistics for all the samples of the given type that have been added to the receiver. If there are no samples of the given type then nil is returned.
        Parameters:
        quantityType - The quantity type to gather statistics about.
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
      • version_static

        public static long version_static()
      • workoutConfiguration

        public HKWorkoutConfiguration workoutConfiguration()
        [@property] workoutConfiguration The configuration for the workout being built.
      • workoutEvents

        public NSArray<? extends HKWorkoutEvent> workoutEvents()
        [@property] workoutEvents Workout events that have been added to the builder. New events that are added using addWorkoutEvents:completion: will be appended to this array once the completion is called.