getLocalActivity method
Gets a local activity.
Parameters
localActivityID: The local id of the activity.onComplete: Called with GemError.success and the activity, or with GemError.notFound and null when there is no such activity.
Returns
- The ProgressListener of the call, or null when it could not start.
Implementation
ProgressListener? getLocalActivity(
int localActivityID, {
void Function(GemError error, Activity? activity)? 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);
if (err != 0) {
onComplete?.call(GemErrorExtension.fromCode(err), null);
return;
}
// The store answers an empty activity when there is none.
final Activity activity = Activity.fromJson(json['result']);
if (activity.localActivityID < 0) {
onComplete?.call(GemError.notFound, null);
} else {
onComplete?.call(GemError.success, activity);
}
});
final OperationResult resultString = objectMethod(
pointerId,
'ActivityStore',
'getLocalActivity',
args: <String, dynamic>{
'id': localActivityID,
'listener': progressListener.id,
},
);
final GemError errorCode = GemErrorExtension.fromCode(
resultString['result'],
);
if (errorCode != GemError.success) {
onComplete?.call(errorCode, null);
return null;
}
return progressListener;
}