Class TmdCloudApi

    • Constructor Summary

      Constructors 
      Constructor Description
      TmdCloudApi()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static Result<java.lang.Boolean> annotate​(android.content.Context context, long timestampStart, long timestampEnd, java.lang.String mode, java.lang.String metadata, VehicleProfile vehicleProfile)
      Label an interval of time with a mode and metadata This information will be forwarded to the cloud even if no corresponding data is available locally
      static Result<java.lang.Boolean> annotate​(android.content.Context context, long timestampStart, long timestampEnd, java.lang.String originalMode, java.lang.String correctedMode, java.lang.String metadata, VehicleProfile vehicleProfile)
      Label an interval of time with a mode and metadata This information will be forwarded to the cloud even if no corresponding data is available locally
      static Result<TmdActivity> annotateActivity​(android.content.Context context, TmdActivity activity, java.lang.String metadata, VehicleProfile vehicleProfile)
      Annotate the activity with new metadata
      static Result<TmdActivity> correctActivity​(android.content.Context context, TmdActivity activity, java.lang.String correctedLabel)
      Correct the label of activity
      static Result<java.util.List<TmdActivity>> fetchData​(android.content.Context context, long start, long end)
      Fetching data from the Moprim cloud
      static Result<java.util.List<TmdActivity>> fetchData​(android.content.Context context, long start, long end, boolean cacheOnly)
      Fetching data from the Moprim cloud
      static Result<java.util.List<TmdActivity>> fetchData​(android.content.Context context, java.util.Date date)
      Fetch TMD activity data from the Moprim Cloud for the defined date
      static Result<java.util.List<TmdActivity>> fetchData​(android.content.Context context, java.util.Date date, boolean cacheOnly)
      Fetch TMD activity data from the Moprim Cloud for the defined date
      static Result<java.util.List<TmdActivity>> fetchData​(android.content.Context context, java.util.Date date, int offsetMinutes)
      Fetch TMD activity data from the Moprim Cloud for the defined date
      static Result<java.util.List<TmdActivity>> fetchData​(android.content.Context context, java.util.Date date, int offsetMinutes, boolean cacheOnly)
      Fetch TMD activity data from the Moprim Cloud for the defined date
      static Result<TmdCloudMetadata> fetchMetadata​(android.content.Context context)
      Fetch the metadata from the Cloud.
      static Result<TmdCloudMetadata> fetchMetadata​(android.content.Context context, boolean cacheOnly)
      Fetch the metadata from the Cloud.
      static Result<java.util.List<TmdStats>> fetchStats​(android.content.Context context, int last)
      Fetching stats from the Moprim cloud
      static android.app.PendingIntent getCallbackIntent()
      Deprecated.
      since 0.5.0, use @link{TMD#getSdkMessenger} instead
      static boolean isMobileDataAllowed​(android.content.Context context)  
      static void setCallbackIntent​(android.app.PendingIntent intent)
      Deprecated.
      since 0.5.0
      static void setDefaultMobileDataAllowed​(android.content.Context context, boolean allowed)
      This method should be called in the Application class to initialize the default use of mobile data for background data upload.
      static void setMobileDataAllowed​(android.content.Context context, boolean mobileDataAllowed)  
      static Result<TmdActivity> updateActivity​(android.content.Context context, TmdActivity activity, java.lang.String correctedLabel, java.lang.String metadata, VehicleProfile vehicleProfile)
      Update the activity with new metadata and a corrected label
      static Result<TmdUploadMetadata> uploadData​(android.content.Context context)
      Upload the collected data to the cloud pro-actively
      static Result<TmdActivity> validateActivity​(android.content.Context context, TmdActivity activity)
      Validate the label of activity
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_ALLOW_MOBILE_DATA

        public static final boolean DEFAULT_ALLOW_MOBILE_DATA
        See Also:
        Constant Field Values
    • Constructor Detail

      • TmdCloudApi

        public TmdCloudApi()
    • Method Detail

      • setCallbackIntent

        @Deprecated
        public static void setCallbackIntent​(android.app.PendingIntent intent)
        Deprecated.
        since 0.5.0
        Sets an callback intent for the background operation with the cloud.
        Parameters:
        intent - the intent to be executed
      • getCallbackIntent

        @Deprecated
        public static android.app.PendingIntent getCallbackIntent()
        Deprecated.
        since 0.5.0, use @link{TMD#getSdkMessenger} instead
        Returns:
        the callback that will be called during background operation with the cloud
      • fetchData

        public static Result<java.util.List<TmdActivity>> fetchData​(@NonNull
                                                                    android.content.Context context,
                                                                    @NonNull
                                                                    java.util.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
      • fetchData

        public static Result<java.util.List<TmdActivity>> fetchData​(@NonNull
                                                                    android.content.Context context,
                                                                    @NonNull
                                                                    java.util.Date date,
                                                                    int offsetMinutes)
        Fetch TMD activity data from the Moprim Cloud for the defined date
        Parameters:
        context - the context
        date - the date
        offsetMinutes - the number of minutes to offset for the date. It can be negative
        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
      • fetchData

        public static Result<java.util.List<TmdActivity>> fetchData​(@NonNull
                                                                    android.content.Context context,
                                                                    @NonNull
                                                                    java.util.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
      • fetchData

        public static Result<java.util.List<TmdActivity>> fetchData​(@NonNull
                                                                    android.content.Context context,
                                                                    @NonNull
                                                                    java.util.Date date,
                                                                    int offsetMinutes,
                                                                    boolean cacheOnly)
        Fetch TMD activity data from the Moprim Cloud for the defined date
        Parameters:
        context - the context
        date - the date
        offsetMinutes - the number of minutes to add to start 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
      • fetchData

        public static Result<java.util.List<TmdActivity>> fetchData​(@NonNull
                                                                    android.content.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
      • fetchData

        public static Result<java.util.List<TmdActivity>> fetchData​(@NonNull
                                                                    android.content.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
      • fetchStats

        public static Result<java.util.List<TmdStats>> fetchStats​(@NonNull
                                                                  android.content.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
      • fetchMetadata

        public static Result<TmdCloudMetadata> fetchMetadata​(@NonNull
                                                             android.content.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 context
        Returns:
        the cloud metadata
      • fetchMetadata

        public static Result<TmdCloudMetadata> fetchMetadata​(@NonNull
                                                             android.content.Context context,
                                                             boolean cacheOnly)
        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 context
        cacheOnly - if true, only check the cache
        Returns:
        the cloud metadata
      • uploadData

        public static Result<TmdUploadMetadata> uploadData​(@NonNull
                                                           android.content.Context context)
        Upload the collected data to the cloud pro-actively
        Parameters:
        context - the context running the request
        Returns:
        how much data was collected
      • validateActivity

        public static Result<TmdActivity> validateActivity​(@NonNull
                                                           android.content.Context context,
                                                           TmdActivity activity)
        Validate the label of activity
        Parameters:
        context - the context
        activity - the activity to validate
        Returns:
        the validated activity
      • correctActivity

        public static Result<TmdActivity> correctActivity​(@NonNull
                                                          android.content.Context context,
                                                          TmdActivity activity,
                                                          java.lang.String correctedLabel)
        Correct the label of activity
        Parameters:
        context - the context
        activity - the activity to correct
        correctedLabel - the new label
        Returns:
        the corrected activity
      • annotateActivity

        public static Result<TmdActivity> annotateActivity​(@NonNull
                                                           android.content.Context context,
                                                           TmdActivity activity,
                                                           java.lang.String metadata,
                                                           VehicleProfile vehicleProfile)
        Annotate the activity with new metadata
        Parameters:
        context - the context
        activity - the activity to correct
        metadata - the metadata
        Returns:
        the annotated activity
      • updateActivity

        public static Result<TmdActivity> updateActivity​(@NonNull
                                                         android.content.Context context,
                                                         TmdActivity activity,
                                                         java.lang.String correctedLabel,
                                                         java.lang.String metadata,
                                                         VehicleProfile vehicleProfile)
        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
      • annotate

        public static Result<java.lang.Boolean> annotate​(@NonNull
                                                         android.content.Context context,
                                                         long timestampStart,
                                                         long timestampEnd,
                                                         java.lang.String mode,
                                                         java.lang.String metadata,
                                                         VehicleProfile vehicleProfile)
        Label an interval of time with a mode and metadata This information will be forwarded to the cloud even if no corresponding data is available locally
        Parameters:
        context - the context
        timestampStart - the start timestamp of the annotation
        timestampEnd - the end timestamp of the annotation
        mode - the mode
        metadata - the metadata
        vehicleProfile - the vehicle profile
        Returns:
        the true if the annotation was successfully saved.
      • annotate

        public static Result<java.lang.Boolean> annotate​(@NonNull
                                                         android.content.Context context,
                                                         long timestampStart,
                                                         long timestampEnd,
                                                         java.lang.String originalMode,
                                                         java.lang.String correctedMode,
                                                         java.lang.String metadata,
                                                         VehicleProfile vehicleProfile)
        Label an interval of time with a mode and metadata This information will be forwarded to the cloud even if no corresponding data is available locally
        Parameters:
        context - the context
        timestampStart - the start timestamp of the annotation
        timestampEnd - the end timestamp of the annotation
        originalMode - the original mode for the activity
        correctedMode - the corrected mode for the activity
        metadata - the metadata
        Returns:
        the true if the annotation was successfully saved.
      • isMobileDataAllowed

        public static boolean isMobileDataAllowed​(@NonNull
                                                  android.content.Context context)
      • setMobileDataAllowed

        public static void setMobileDataAllowed​(@NonNull
                                                android.content.Context context,
                                                boolean mobileDataAllowed)
      • setDefaultMobileDataAllowed

        public static void setDefaultMobileDataAllowed​(@NonNull
                                                       android.content.Context context,
                                                       boolean allowed)
        This method should be called in the Application class to initialize the default use of mobile data for background data upload. Nothing happens if the
        Parameters:
        context - the context of the application
        allowed - if the use of mobile data is allow by default or not