Class ClientResourceService
-
- All Implemented Interfaces:
public final class ClientResourceService extends MobileService
Represents the service to handle client resource related cases, for example,
<ul> <li>Automatically download the default client resource when app is brought to foreground.</li> <li>Retrieve the resource bundle information from mobile server.</li> <li>Download a specified resource bundle then save it a local file.</li> </ul>
-
-
Constructor Summary
Constructors Constructor Description ClientResourceService(ServiceListener<ByteArray> autoDownloadListener)
-
Method Summary
Modifier and Type Method Description Unitinit(Application application, String apiKey)Initializes the mobile service UnitonStateChange(ApplicationState state)Notified when application state changes. final JobdownloadResourceToFile(ServiceListener<String> listener, String fileName, ClientResourceBundle bundle, Boolean overwrite)Downloads the client resource and save the content to a file identified by fileName, if bundle is not specified, the default client resource will be downloaded. final JobdownloadClientResource(ServiceListener<ByteArray> listener, ClientResourceBundle bundle)Download client resource content, if bundle is not specified, download the default resource. final ServiceResult<ByteArray>downloadClientResource(ClientResourceBundle bundle)Downloads the client resource content for the given bundle. final JobretrieveResourceBundles(ServiceListener<List<ClientResourceBundle>> listener)Retrieves the resource bundle list from server, and notifies the result with the given listener. final ServiceResult<List<ClientResourceBundle>>retrieveResourceBundles()Retrieves the client resource bundle list from server. -
-
Constructor Detail
-
ClientResourceService
ClientResourceService(ServiceListener<ByteArray> autoDownloadListener)
-
-
Method Detail
-
init
Unit init(Application application, String apiKey)
Initializes the mobile service
-
onStateChange
Unit onStateChange(ApplicationState state)
Notified when application state changes. This function will be called on Main thread.
-
downloadResourceToFile
final Job downloadResourceToFile(ServiceListener<String> listener, String fileName, ClientResourceBundle bundle, Boolean overwrite)
Downloads the client resource and save the content to a file identified by fileName, if bundle is not specified, the default client resource will be downloaded. The saved file is located in the internal storage of this mobile application, the client code can then access the file with: <code>val file = File(context.filesDir, filename)</code>
-
downloadClientResource
final Job downloadClientResource(ServiceListener<ByteArray> listener, ClientResourceBundle bundle)
Download client resource content, if bundle is not specified, download the default resource.
-
downloadClientResource
final ServiceResult<ByteArray> downloadClientResource(ClientResourceBundle bundle)
Downloads the client resource content for the given bundle. This fun will be executed in a worker thread.
-
retrieveResourceBundles
final Job retrieveResourceBundles(ServiceListener<List<ClientResourceBundle>> listener)
Retrieves the resource bundle list from server, and notifies the result with the given listener.
-
retrieveResourceBundles
final ServiceResult<List<ClientResourceBundle>> retrieveResourceBundles()
Retrieves the client resource bundle list from server. This function will be executed in a worker thread.
-
-
-
-