Skip to main content

Activities

The Activities module provides calendar-based access to a member's activity history. Query by month and year to retrieve aggregate statistics and individual activity records -- gym visits, step tracking, self-reports, and at-home workouts.


UI Reference

Build a monthly calendar that color-codes each day by activity type and status. Use get(month, year) to populate the grid and summary statistics.

Activity calendar showing iOS (Apple HIG) and Android (Material Design 3) implementations with color-coded activity indicators for gym visits, SmartWalking, Fit@Home, and pending activities

Key data mappings:

UI ElementAFCore Source
Month header & progress barmonthlySummary.acceptedActivities / monthlySummary.acceptedVisitGoalDays
Day activity dotsactivities grouped by date, colored by ActivityType
Summary countersmonthlySummary.acceptedActivities, .pendingActivities, .rejectedActivities
Legend colorsGYM_VISIT_ACTIVITY (green), SMART_WALKING_ACTIVITY (blue), HOME_ACTIVITY (orange)

Data Model

AFActivitiesSummary

Returned by get(), this contains both the monthly aggregate and the list of individual activities.

FieldTypeDescription
monthlySummaryMonthlySummary?Aggregate statistics for the requested month.
activitiesList<Activity>Individual activity records for the month.

MonthlySummary

FieldTypeDescription
monthIntCalendar month (1--12).
yearIntCalendar year.
acceptedVisitGoalDaysIntNumber of days the visit goal was met.
acceptedVisitDaysIntNumber of days with at least one accepted visit.
acceptedActivitiesIntTotal accepted activities in the month.
pendingActivitiesIntActivities awaiting verification.
rejectedActivitiesIntActivities that were denied.

Activity

FieldTypeDescription
typeActivityType?Category of the activity.
nameString?Display name (e.g., facility name or "SmartWalking").
iconResString?Optional icon resource identifier.
statusTypeActivityStatusCurrent verification status.
dateString?Date of the activity (ISO-8601).
metaDataActivityMetaData?Additional details specific to the activity type.
messageString?Server message (e.g., rejection reason).

ActivityType

ValueKeyDescription
GYM_VISIT_ACTIVITY"gym"Facility visit detected by geofencing.
SMART_WALKING_ACTIVITY"walking"Step-based activity from SmartWalking.
SELF_REPORTED_ACTIVITY"mobileSelfReport"Manually submitted visit report.
HOME_ACTIVITY"fitAtHome"At-home workout verified by selfie.

ActivityStatus

ValueDescription
APPROVED / ACCEPTED / COMPLETEDActivity was verified and counts toward goals. Treat these as equivalent.
PENDINGActivity is awaiting verification or still in progress.
DENIED / REJECTEDActivity did not pass validation. Check Activity.message for the reason.
PARTIALActivity was recorded but did not meet the required threshold (e.g., insufficient steps).
IGNORERecorded for tracking purposes only; does not count toward goals.
DEFAULTFallback when the server returns an unmapped status.

ActivityMetaData

FieldTypeDescription
facilityIdInt?Facility identifier.
facilityNameString?Display name of the facility.
addressString?Street address.
cityString?City.
stateString?Two-letter state code.
descriptionString?Description (used for custom activity types).
timeSpentInt?Duration in minutes.
stepsInt?Step count (SmartWalking activities).
distanceDouble?Distance traveled.
distanceUnitString?Unit of distance ("Miles" or "Kilometers").
caloriesDouble?Calories burned (SmartWalking activities).
activeMinutesInt?Active minutes (SmartWalking activities).
lastSyncString?Timestamp of the last sync for this activity.

Get Activities

Retrieve the monthly summary and activity list for a given month and year.

lifecycleScope.launch {
try {
val result = AFCore.activities().get(month = 2, year = 2026)

// Display monthly progress
result.monthlySummary?.let { summary ->
progressBar.max = summary.acceptedVisitGoalDays
progressBar.progress = summary.acceptedVisitDays
summaryLabel.text = "${summary.acceptedActivities} accepted, " +
"${summary.pendingActivities} pending, " +
"${summary.rejectedActivities} rejected"
}

// Group activities by date for a calendar view
val activitiesByDate = result.activities
.groupBy { it.date?.substringBefore("T") }

calendarAdapter.submitGrouped(activitiesByDate)

} catch (e: Exception) {
showError("Could not load activities: ${e.message}")
}
}

Rendering Activities by Type

Each activity type carries different metadata. Use the type field to determine which details to display.

// Android -- render an activity card based on type
fun renderActivity(activity: Activity) {
titleLabel.text = activity.name
dateLabel.text = activity.date
statusIcon.setImageResource(statusIconFor(activity.statusType))

when (activity.type) {
ActivityType.GYM_VISIT_ACTIVITY -> {
subtitleLabel.text = activity.metaData?.facilityName
detailLabel.text = "${activity.metaData?.timeSpent ?: 0} min"
}
ActivityType.SMART_WALKING_ACTIVITY -> {
subtitleLabel.text = "${activity.metaData?.steps ?: 0} steps"
detailLabel.text = "${activity.metaData?.calories ?: 0} cal"
}
ActivityType.SELF_REPORTED_ACTIVITY -> {
subtitleLabel.text = activity.metaData?.facilityName
detailLabel.text = "Self-reported"
}
ActivityType.HOME_ACTIVITY -> {
subtitleLabel.text = "At-home workout"
detailLabel.text = activity.metaData?.description
}
else -> {
subtitleLabel.text = activity.message
}
}
}

Best Practices

  • Query one month at a time. The API is calendar-based. To build a scrollable history, load each month as the user navigates backward.
  • Color-code by status. Use distinct colors for accepted (green), pending (yellow), and rejected (red) activities in calendar and list views.
  • Treat APPROVED, ACCEPTED, and COMPLETED as equivalent. The server may return any of these for verified activities. Normalize them in your UI logic.
  • Show rejection reasons. When statusType is DENIED or REJECTED, display activity.message so the member understands why.
  • Pull-to-refresh the current month, since activities can change as visits are verified or step data is processed.

Quick Reference

// Android
AFCore.activities().get(month = 2, year = 2026) // Returns AFActivitiesSummary