ActivityStore class Activity Store

Local-first activity storage, synced with the backend.

The local SQLite store is the system of record and works offline: activities, their files, the user profile and the shared activities the user kept. Activities sync with the backend when ActivityStoreConfig.syncEnabled is true and a session is set with setSession; the profile syncs whenever a session is set. The asynchronous outcomes reach the listeners added with addListener.

Every method runs on the SDK thread and reports its outcome to its onComplete callback. A method returns the ProgressListener of the call, or null when the call could not start, in which case onComplete has already been called with the error.

See also:

Annotations

Properties

hashCode → int
The hash code for this object.
no setterinherited
hasRegisteredAutoReleaseObject ↔ bool
getter/setter pairinherited
pointerId → int
The pointer ID of the native object
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addActivityFile({required int localActivityID, required StoredActivityFile file, required String localFilePath, void onComplete(GemError error, int localFileID)?}) → ProgressListener?
Attaches a device file, such as a route thumbnail, photo or video, to a local activity.
addListener(ActivityStoreListener listener, {void onComplete(GemError error)?}) → ProgressListener?
Adds a listener for the asynchronous events of this store.
deleteActivity(int localActivityID, {void onComplete(GemError error)?}) → ProgressListener?
Deletes a local activity; the deletion reaches the server on the next sync.
dispose() → void
Disposes the native object.
inherited
downloadActivityFile(int localActivityID, {void onComplete(GemError error)?}) → ProgressListener?
Downloads the recorded track of a synced activity to the device, for example on a new device.
fetchRemoteActivities(String userID, {void onComplete(GemError error)?}) → ProgressListener?
Pulls the activities of a user from the server and merges them into the local store.
fetchRemoteUserProfile(String userID, {void onComplete(GemError error)?}) → ProgressListener?
Pulls the profile of a user from the server and merges it into the local store.
fetchSharedActivityByToken(String shareToken, {void onComplete(GemError error)?}) → ProgressListener?
Resolves a shared activity from the share token of its link.
getLocalActivity(int localActivityID, {void onComplete(GemError error, Activity? activity)?}) → ProgressListener?
Gets a local activity.
getShareableUrlForToken(String shareToken, {void onComplete(GemError error, String url)?}) → ProgressListener?
Builds the share link of an activity.
getSharedActivity({required String recipientUserID, required String shareToken, void onComplete(GemError error, Activity? activity)?}) → ProgressListener?
Gets a shared activity kept by a user.
getSharedFileUrl(String shareToken, int activityFileID, {void onComplete(GemError error, String url)?}) → ProgressListener?
Builds the download URL of a file of a shared activity.
getUserProfile(String userID, {void onComplete(GemError error, UserProfile? profile)?}) → ProgressListener?
Gets the locally stored profile of a user.
insertActivity(Activity activity, {required String fitFilePath, void onComplete(GemError error, int localActivityID)?}) → ProgressListener?
Stores a new activity locally and queues it for sync.
isSignedIn({void onComplete(GemError error, bool signedIn)?}) → ProgressListener?
Checks whether a session is set, refreshable when its access token expired.
listLocalActivities(String userID, {void onComplete(GemError error, List<Activity> activities)?}) → ProgressListener?
Lists the local activities of a user, newest first.
listSharedActivities(String recipientUserID, {void onComplete(GemError error, List<Activity> activities)?}) → ProgressListener?
Lists the shared activities kept by a user, newest first.
markSharedActivityRevoked({required String recipientUserID, required String shareToken, void onComplete(GemError error)?}) → ProgressListener?
Marks a kept shared activity as revoked, after fetchSharedActivityByToken reported ActivityStoreResult.serverError because its owner made it private or deleted it.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
purgeLocalUserData(String userID, {void onComplete(GemError error)?}) → ProgressListener?
Deletes all the local data of a user, for example when the account is deleted.
registerAutoReleaseObject(int pointerId) → void
Registers an object for auto release.
inherited
removeActivityFile(int localFileID, {void onComplete(GemError error)?}) → ProgressListener?
Removes a file attached to a local activity.
removeListener(ActivityStoreListener listener, {void onComplete(GemError error)?}) → ProgressListener?
Removes a listener added with addListener.
removeSharedActivity({required String recipientUserID, required String shareToken, void onComplete(GemError error)?}) → ProgressListener?
Drops a kept shared activity and deletes its cached files.
saveSharedActivity({required String recipientUserID, required Activity activity, void onComplete(GemError error)?}) → ProgressListener?
Keeps a shared activity the user opened from a link, or refreshes the kept copy.
setSession({required String accessToken, required String refreshToken, required int expiresInSec, void onComplete(GemError error)?}) → ProgressListener?
Hands over the session obtained by the app's sign-in flow.
signOut({void onComplete(GemError error)?}) → ProgressListener?
Clears the local session. The session is not revoked on the server.
syncPending({void onComplete(GemError error)?}) → ProgressListener?
Uploads the local activities that are new or changed.
toString() → String
A string representation of this object.
inherited
touchSharedActivityValidated({required String recipientUserID, required String shareToken, void onComplete(GemError error)?}) → ProgressListener?
Records that a kept shared activity is still shared, after a successful fetchSharedActivityByToken. Clears Activity.revoked.
updateActivity(Activity activity, {void onComplete(GemError error)?}) → ProgressListener?
Saves the changes made to a local activity and queues it for sync.
upsertUserProfile(UserProfile profile, {void onComplete(GemError error)?}) → ProgressListener?
Saves a profile locally, keyed by UserProfile.userID, and queues it for sync.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

create(ActivityStoreConfig config) → ActivityStore?
Creates an ActivityStore, opening or creating its local store.