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>
-
-
Field Summary
Fields Modifier and Type Field Description public final static String
VERSION
public final static String
BUNDLE
private Application
application
private String
apiKey
-
Constructor Summary
Constructors Constructor Description ClientResourceService(ServiceListener<ByteArray> autoDownloadListener)
-
Method Summary
Modifier and Type Method Description Unit
init(Application application, String apiKey)
Initializes the mobile service Unit
onStateChange(ApplicationState state)
Notified when application state changes. 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. final Job
downloadClientResource(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 Job
retrieveResourceBundles(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. -
Methods inherited from class com.sap.cloud.mobile.foundation.mobileservices.MobileService
enableNetworkPolicy, getApiKey, getApplication, isApplicationInitialized, mayStartNewProcess, reset, setApiKey, setApplication
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
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.
-
-
-
-