public class

TmdCloudApi

extends Object
java.lang.Object
   ↳ fi.moprim.tmd.sdk.TmdCloudApi

Class Overview

This class offers static functions to interact with the Moprim Cloud. Most common use cases are fetching data and metadata and uploading data to the sync.

Summary

Public Constructors
TmdCloudApi()
Public Methods
static Result<TmdActivity> annotateActivity(Context context, TmdActivity activity, String metadata)
Annotate the activity with new metadata
static Result<TmdActivity> correctActivity(Context context, TmdActivity activity, String correctedLabel)
Correct the label of activity
static Result<List<TmdActivity>> fetchData(Context context, Date date, boolean cacheOnly)
Fetch TMD activity data from the Moprim Cloud for the defined date
static Result<List<TmdActivity>> fetchData(Context context, Date date)
Fetch TMD activity data from the Moprim Cloud for the defined date
static Result<List<TmdActivity>> fetchData(Context context, long start, long end)
Fetching data from the Moprim cloud
static Result<List<TmdActivity>> fetchData(Context context, long start, long end, boolean cacheOnly)
Fetching data from the Moprim cloud
static Result<TmdCloudMetadata> fetchMetadata(Context context)
Fetch the metadata from the Cloud.
static Result<TmdStats> fetchStats(Context context, int last, boolean cacheOnly)
Fetching stats from the Moprim cloud
static Result<TmdStats> fetchStats(Context context, int last)
Fetching stats from the Moprim cloud
static PendingIntent getUploadCallbackIntent()
static void setUploadCallbackIntent(PendingIntent intent)
Sets an upload callback intent for the period upload.
static Result<TmdActivity> updateActivity(Context context, TmdActivity activity, String correctedLabel, String metadata)
Update the activity with new metadata and a corrected label
static Result<TmdUploadMetadata> uploadData(Context context)
Upload the collected data to the cloud pro-actively
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public TmdCloudApi ()

Public Methods

public static Result<TmdActivity> annotateActivity (Context context, TmdActivity activity, String metadata)

Annotate the activity with new metadata

Parameters
context the context
activity the activity to correct
metadata the metadata
Returns
  • the annotated activity

public static Result<TmdActivity> correctActivity (Context context, TmdActivity activity, String correctedLabel)

Correct the label of activity

Parameters
context the context
activity the activity to correct
correctedLabel the new label
Returns
  • the corrected activity

public static Result<List<TmdActivity>> fetchData (Context context, Date date, boolean cacheOnly)

Fetch TMD activity data from the Moprim Cloud for the defined date

Parameters
context the context
date the date
cacheOnly set to true if you wish to use the cache only
Returns
  • a list of TMD activities if successful, an error otherwise. If this method fails but cached data is available, error message can be accessed

public static Result<List<TmdActivity>> fetchData (Context context, Date date)

Fetch TMD activity data from the Moprim Cloud for the defined date

Parameters
context the context
date the date
Returns
  • a list of TMD activities if successful, an error otherwise. If this method fails but cached data is available, error message can be accessed

public static Result<List<TmdActivity>> fetchData (Context context, long start, long end)

Fetching data from the Moprim cloud

Parameters
context the context
start the start time (timestamp in ms)
end the end time (timestamp in ms)
Returns
  • a list of cached activities

public static Result<List<TmdActivity>> fetchData (Context context, long start, long end, boolean cacheOnly)

Fetching data from the Moprim cloud

Parameters
context the context
start the start time (timestamp in ms)
end the end time (timestamp in ms)
cacheOnly set to true if you wish not to request data from the cloud
Returns
  • a list of cached activities

public static Result<TmdCloudMetadata> fetchMetadata (Context context)

Fetch the metadata from the Cloud. This function is usually called when one wants to know what data can be fetched from the Cloud

Parameters
context the contect
Returns
  • the cloud metadata

public static Result<TmdStats> fetchStats (Context context, int last, boolean cacheOnly)

Fetching stats from the Moprim cloud

Parameters
context the context
last the number of days for the last period
cacheOnly set to true if you wish not to request stats from the cloud
Returns
  • the stats

public static Result<TmdStats> fetchStats (Context context, int last)

Fetching stats from the Moprim cloud

Parameters
context the context
last the number of days for the last period
Returns
  • the stats

public static PendingIntent getUploadCallbackIntent ()

Returns
  • the callback that will be called during the period update of the data to the cloud

public static void setUploadCallbackIntent (PendingIntent intent)

Sets an upload callback intent for the period upload.

Parameters
intent the intent to be executed

public static Result<TmdActivity> updateActivity (Context context, TmdActivity activity, String correctedLabel, String metadata)

Update the activity with new metadata and a corrected label

Parameters
context the context
activity the activity to correct
correctedLabel the new label
metadata the metadata
Returns
  • the updated activity

public static Result<TmdUploadMetadata> uploadData (Context context)

Upload the collected data to the cloud pro-actively

Returns
  • how much data was collected