asyncDownload method
- void onCompleteCallback(
- GemError err
- void onProgressCallback(
- int progress
- bool allowChargedNetworks = false,
- DataSavePolicy savePolicy = DataSavePolicy.useDefault,
- ContentDownloadThreadPriority priority = ContentDownloadThreadPriority.defaultPriority,
Asynchronous start/resume the download of the content store product content.
Requires automatic map rendering. Disables the cursor if enabled.
Parameters
- IN onCompleteCallback Object that implements notification event associated with operation completion. Cannot be empty. Returns GemError.success on success, otherwise see GemError for other values.
- IN onProgressCallback Object that implements notification event associated with operation progress.
- IN allowChargedNetworks Flag whether to allow charged networks. If true, it will override SdkSettings.setAllowOffboardServiceOnExtraChargedNetwork ( [ServiceGroupType.contentService, false ).
- IN savePolicy Specify where the download will be made (optional).
Returns
- The associated ProgressListener
Throws
- An exception if it fails
Implementation
ProgressListener asyncDownload(
final void Function(GemError err) onCompleteCallback, {
final void Function(int progress)? onProgressCallback,
final bool allowChargedNetworks = false,
final DataSavePolicy savePolicy = DataSavePolicy.useDefault,
final ContentDownloadThreadPriority priority =
ContentDownloadThreadPriority.defaultPriority,
}) {
final EventDrivenProgressListener progListener =
EventDrivenProgressListener();
final OperationResult resultString = objectMethod(
_pointerId,
'ContentStoreItem',
'asyncDownload',
args: <String, dynamic>{
'listener': progListener.id,
'allowChargedNetworks': allowChargedNetworks,
'savePolicy': savePolicy.id,
'priority': priority.id,
},
);
if (resultString is Map && resultString.containsKey('error')) {
onCompleteCallback(GemErrorExtension.fromCode(resultString['error']));
return EventDrivenProgressListener.init(0);
}
if (onProgressCallback != null) {
progListener.registerOnProgressCallback((final int p0) {
onProgressCallback(p0);
});
}
progListener.registerOnCompleteWithDataCallback((
final int err,
final String hint,
final Map<dynamic, dynamic> json,
) {
if (err == 0) {
onCompleteCallback(GemErrorExtension.fromCode(0));
//onCompleteCallback(err, result.getJson());
} else {
onCompleteCallback(GemErrorExtension.fromCode(err));
}
});
GemKitPlatform.instance.registerEventHandler(progListener.id, progListener);
return progListener;
}