updateActivity method
Saves the changes made to a local activity and queues it for sync.
Saved are the title, the location, the metrics and the sport type, effort, visibility and long description of Activity.record; the store sets Activity.updatedAtMillis.
Parameters
activity: The activity, identified by its Activity.localActivityID.onComplete: Called with GemError.success, or another GemError when the activity is not found or could not be saved.
Returns
- The ProgressListener of the call, or null when it could not start.
Implementation
ProgressListener? updateActivity(
Activity activity, {
void Function(GemError error)? onComplete,
}) {
final EventDrivenProgressListener progressListener =
EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(
progressListener.id,
progressListener,
);
progressListener.registerOnCompleteWithData((
int err,
String hint,
Map<dynamic, dynamic> json,
) {
GemKitPlatform.instance.unregisterEventHandler(progressListener.id);
onComplete?.call(GemErrorExtension.fromCode(err));
});
final OperationResult resultString = objectMethod(
pointerId,
'ActivityStore',
'updateActivity',
args: <String, dynamic>{
'activity': activity.toJson(),
'listener': progressListener.id,
},
);
final GemError errorCode = GemErrorExtension.fromCode(
resultString['result'],
);
if (errorCode != GemError.success) {
onComplete?.call(errorCode);
return null;
}
return progressListener;
}