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. API-Since: 12.0
    • Constructor Detail

      • HKWorkoutBuilder

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

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • addMetadataCompletion

        public void addMetadataCompletion​(@NotNull
                                          @NotNull NSDictionary<java.lang.String,​?> metadata,
                                          @NotNull
                                          @NotNull 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​(@NotNull
                                         @NotNull NSArray<? extends HKSample> samples,
                                         @NotNull
                                         @NotNull 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​(@NotNull
                                               @NotNull NSArray<? extends HKWorkoutEvent> workoutEvents,
                                               @NotNull
                                               @NotNull 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 HKWorkoutBuilder allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

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

        public void beginCollectionWithStartDateCompletion​(@NotNull
                                                           @NotNull NSDate startDate,
                                                           @NotNull
                                                           @NotNull 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​(@NotNull
                                                                   @NotNull java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

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

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

        @NotNull
        public static @NotNull 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

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

        public void discardWorkout()
        discardWorkout Finishes building the workout and discards the 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​(@NotNull
                                        @NotNull 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​(@NotNull
                                                       @NotNull NSDate endDate,
                                                       @NotNull
                                                       @NotNull 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

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

        public void finishWorkoutWithCompletion​(@NotNull
                                                @NotNull 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 the returned workout is nil, an error may have occurred in which case error will be non-nil. If both workout and error are nil then finishing the workout succeeded but the workout sample is not available because the device is locked.
      • hash_static

        public static long hash_static()
      • initWithHealthStoreConfigurationDevice

        public HKWorkoutBuilder initWithHealthStoreConfigurationDevice​(@NotNull
                                                                       @NotNull HKHealthStore healthStore,
                                                                       @NotNull
                                                                       @NotNull HKWorkoutConfiguration configuration,
                                                                       @Nullable
                                                                       @Nullable 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

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

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

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

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

        @Nullable
        public @Nullable HKSeriesBuilder seriesBuilderForType​(@NotNull
                                                              @NotNull 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

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

        @Nullable
        public @Nullable HKStatistics statisticsForType​(@NotNull
                                                        @NotNull 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

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

        @NotNull
        public @NotNull 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.
      • addWorkoutActivityCompletion

        public void addWorkoutActivityCompletion​(@NotNull
                                                 @NotNull HKWorkoutActivity workoutActivity,
                                                 @NotNull
                                                 @NotNull HKWorkoutBuilder.Block_addWorkoutActivityCompletion completion)
        addWorkoutActivity:completion: Adds a new workout activity to the builder instance. This method can be called many times to add workout activities 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:
        workoutActivity - The activity to add to the builder.
        completion - Block to be called when the addition of the activity to the builder is complete. If success is YES, the activity was added to the builder successfully. If success is NO, error will be non-null and will contain the error encountered during the insertion operation. API-Since: 16.0
      • allStatistics

        @NotNull
        public @NotNull NSDictionary<? extends HKQuantityType,​? extends HKStatistics> allStatistics()
        [@property] allStatistics A dictionary of statistics per quantity type added to the builder This dictionary will contain HKStatistics objects containing the statistics by quantity sample type for all of the samples that have been added to the builder. API-Since: 16.0
      • updateActivityWithUUIDAddMedatataCompletion

        public void updateActivityWithUUIDAddMedatataCompletion​(@NotNull
                                                                @NotNull NSUUID UUID,
                                                                @NotNull
                                                                @NotNull NSDictionary<java.lang.String,​?> metadata,
                                                                @NotNull
                                                                @NotNull HKWorkoutBuilder.Block_updateActivityWithUUIDAddMedatataCompletion completion)
        updateActivityWithUUID:addMetadata:completion: Adds new metadata to an already added activity. 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:]. 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:
        UUID - The UUID of the workout activity to update.
        metadata - The metadata to add to the workout activity.
        completion - Block to be called when the addition of metadata to the activity is complete. If success is YES, the metadata has been added to the activity 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 activity's metadata property will remain unchanged. API-Since: 16.0
      • updateActivityWithUUIDEndDateCompletion

        public void updateActivityWithUUIDEndDateCompletion​(@NotNull
                                                            @NotNull NSUUID UUID,
                                                            @NotNull
                                                            @NotNull NSDate endDate,
                                                            @NotNull
                                                            @NotNull HKWorkoutBuilder.Block_updateActivityWithUUIDEndDateCompletion completion)
        updateActivityWithUUID:endDate:completion: Sets the end date on an already added activity. 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:
        UUID - The UUID of the workout activity to update.
        endDate - The end date to set on the activity
        completion - Block to be called when the update of the end date on the activity is complete. If success is YES, the end date was set to the actvity successfully. If success is NO, error will be non-null and will contain the error encountered during the update operation. API-Since: 16.0
      • workoutActivities

        @NotNull
        public @NotNull NSArray<? extends HKWorkoutActivity> workoutActivities()
        [@property] workoutActivities Workout activities that have been added to the builder. New activities that are added using addWorkoutActivity:completion: will be appended to this array once the completion is called. API-Since: 16.0
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.