Package fi.moprim.tmd.sdk.data
Class VehicleProfileRepository
- java.lang.Object
-
- fi.moprim.tmd.sdk.data.VehicleProfileRepository
-
public class VehicleProfileRepository extends java.lang.Object
Repository singleton module for handling vehicle profile data operations. Collecting VehicleProfile data is main-safe. This repository moves the query execution off of the main thread. It also supports fetching data from the cloud.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description androidx.lifecycle.LiveData<Resource<VehicleProfile>>
addVehicleProfile(android.content.Context context, java.lang.String name, Mode mode, Energy energy, java.lang.String make, java.lang.String makeAlt, java.lang.String model, java.lang.String modelAlt, java.lang.String year, java.lang.Boolean owner, boolean defaultVehicle)
androidx.lifecycle.LiveData<Resource<VehicleProfile>>
deleteVehicleProfile(android.content.Context context, java.lang.String id)
void
forceUpload(android.content.Context context)
Force the upload of TMD data to the Moprim Cloud.static VehicleProfileRepository
getInstance()
Getting an instance of the repository with default executorsandroidx.lifecycle.LiveData<VehicleProfile>
getVehicleProfile(android.content.Context context, java.lang.String id)
RefreshLiveData<Resource<java.util.List<VehicleProfile>>>
getVehicleProfiles(android.content.Context context)
Loads vehicle profiles from the cloud or the cacheVehicleProfileRepository
setMinimumIntervalBetweenNetworkRequests(long timeMs)
androidx.lifecycle.LiveData<Resource<VehicleProfile>>
updateVehicleProfile(android.content.Context context, java.lang.String id, java.lang.String name, Mode mode, Energy energy, java.lang.String make, java.lang.String makeAlt, java.lang.String model, java.lang.String modelAlt, java.lang.String year, java.lang.Boolean owner, boolean defaultVehicle)
-
-
-
Method Detail
-
getInstance
public static VehicleProfileRepository getInstance()
Getting an instance of the repository with default executors- Returns:
- a singleton instance of the repository
-
setMinimumIntervalBetweenNetworkRequests
public VehicleProfileRepository setMinimumIntervalBetweenNetworkRequests(long timeMs)
-
forceUpload
public void forceUpload(@NonNull android.content.Context context)
Force the upload of TMD data to the Moprim Cloud.- Parameters:
context
- the context triggering the upload
-
getVehicleProfiles
public RefreshLiveData<Resource<java.util.List<VehicleProfile>>> getVehicleProfiles(@NonNull android.content.Context context)
Loads vehicle profiles from the cloud or the cache- Parameters:
context
- the context running the request- Returns:
- the LiveData with the list of vehicle profiles embedded in a Resource wrapper to know about the status of the request
-
addVehicleProfile
public androidx.lifecycle.LiveData<Resource<VehicleProfile>> addVehicleProfile(@NonNull android.content.Context context, @NonNull java.lang.String name, @NonNull Mode mode, @NonNull Energy energy, java.lang.String make, java.lang.String makeAlt, java.lang.String model, java.lang.String modelAlt, java.lang.String year, java.lang.Boolean owner, boolean defaultVehicle)
-
updateVehicleProfile
public androidx.lifecycle.LiveData<Resource<VehicleProfile>> updateVehicleProfile(@NonNull android.content.Context context, @NonNull java.lang.String id, @NonNull java.lang.String name, @NonNull Mode mode, @NonNull Energy energy, java.lang.String make, java.lang.String makeAlt, java.lang.String model, java.lang.String modelAlt, java.lang.String year, java.lang.Boolean owner, boolean defaultVehicle)
-
deleteVehicleProfile
public androidx.lifecycle.LiveData<Resource<VehicleProfile>> deleteVehicleProfile(@NonNull android.content.Context context, @NonNull java.lang.String id)
-
getVehicleProfile
public androidx.lifecycle.LiveData<VehicleProfile> getVehicleProfile(@NonNull android.content.Context context, @NonNull java.lang.String id)
-
-