Package es.situm.sdk.communication
Interface CommunicationManager
public interface CommunicationManager
The Communication manager allows you to make asynchronous requests to the server, mostly to fetch data.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThe error codes received inHandler.onFailure(Error)on theCommunicationManagerstatic interface -
Method Summary
Modifier and TypeMethodDescriptionbooleancreateOccurrenceForEvent(SitumEvent event, Handler<EventOccurrence> callback) Create an occurrence for an event.booleanfetchAllPOIsFromUser(CommunicationConfig config, Handler<Collection<Poi>> callback) Download the POIs from all the buildings of the userbooleanfetchAllPOIsFromUser(Handler<Collection<Poi>> callback) Download the POIs from all the buildings of the userbooleanfetchBuildingInfo(String buildingId, CommunicationConfig config, Handler<BuildingInfo> callback) Download all the building data from the selected building.booleanfetchBuildingInfo(String buildingId, Handler<BuildingInfo> callback) Download all the building data for the selected building.booleanfetchBuildings(CommunicationConfig config, Handler<Collection<Building>> callback) Download all the buildings for the current userbooleanfetchBuildings(Handler<Collection<Building>> callback) Download all the buildings for the current userbooleanfetchClosestPOIs(Location location, String poiCategoryIdentifier, int limit, es.situm.sdk.directions.DistanceAlgorithm distanceAlgorithm, Handler<Collection<PoiWithDistance>> callback) Returns a list of indoor POIs ordered from closest to furthest with respect to the givenLocation.booleanfetchEventsFromBuilding(String buildingId, CommunicationConfig config, Handler<Collection<SitumEvent>> callback) Download the events of a buildingbooleanfetchEventsFromBuilding(String buildingId, Handler<Collection<SitumEvent>> callback) Download the events of a buildingbooleanfetchFloorsFromBuilding(String buildingId, CommunicationConfig config, Handler<Collection<Floor>> callback) Download all the floors of a buildingbooleanfetchFloorsFromBuilding(String buildingId, Handler<Collection<Floor>> callback) Download all the floors of a buildingbooleanfetchGeofencesFromBuilding(Building building, CommunicationConfig config, Handler<List<Geofence>> callback) Get the geofences of a buildingbooleanfetchGeofencesFromBuilding(Building building, Handler<List<Geofence>> callback) Get the geofences of a buildingbooleanfetchIndoorPOIFromBuilding(String poiId, String buildingId, CommunicationConfig config, Handler<Poi> callback) Download the given indoor POI of a building.booleanfetchIndoorPOIFromBuilding(String poiId, String buildingId, Handler<Poi> callback) Download the given indoor POI of a building.booleanfetchIndoorPOIsFromBuilding(String buildingId, CommunicationConfig config, Handler<Collection<Poi>> callback) Download the indoor POIs of a buildingbooleanfetchIndoorPOIsFromBuilding(String buildingId, Handler<Collection<Poi>> callback) Download the indoor POIs of a buildingbooleanfetchMapFromFloor(Floor floor, CommunicationConfig config, Handler<android.graphics.Bitmap> callback) Download the map image of a floorbooleanfetchMapFromFloor(Floor floor, Handler<android.graphics.Bitmap> callback) Download the map image of a floorbooleanfetchOrganizationTheme(Handler<OrganizationTheme> callback) Get organization theme: company name, logo and colorsbooleanfetchOutdoorPOIsFromBuilding(String buildingId, CommunicationConfig config, Handler<Collection<Poi>> callback) Download the outdoor POIs of a buildingbooleanfetchOutdoorPOIsFromBuilding(String buildingId, Handler<Collection<Poi>> callback) Download the outdoor POIs of a buildingbooleanfetchPoiCategories(CommunicationConfig config, Handler<Collection<PoiCategory>> callback) Get all POI categories, download and cache their icons asynchronously.booleanfetchPoiCategories(Handler<Collection<PoiCategory>> callback) Get all POI categories, download and cache their icons asynchronouslybooleanfetchPoiCategoryIcon(PoiCategory category, boolean selected, CommunicationConfig config, Handler<android.graphics.Bitmap> callback) Get the normal category icon for a categorybooleanfetchPoiCategoryIcon(PoiCategory category, boolean selected, Handler<android.graphics.Bitmap> callback) Get the normal category icon for a categorybooleanfetchRailWidth(String buildingId, Handler<Float> callback) Get the calibrations rail width used in a buildingbooleanfetchRemoteConfig(LocationRequest locationRequest, Handler<RemoteConfig> callback) Get theRemoteConfigfor the current user.booleanfetchRemoteConfig(Handler<RemoteConfig> callback) Get theRemoteConfigfor the current user.booleanfetchTilesFromBuilding(String buildingId, Handler<String> callback) Download the building Tiles.Return the HTTP Request Executor to make custom requests to the DashboardgetTileFromBuilding(String buildingId, String floorId, int x, int y, int zoom) Returns a specific image tile for a building and floor combination.voidInvalidate all the resources in the cachevoidInvalidate all tiles resourcesbooleanEnds the user session.booleanprefetchPositioningInfo(CommunicationConfig config, Handler<String> callback) Download all the necessary information to start positioning.booleanprefetchPositioningInfo(Handler<String> callback) Download all the necessary information to start positioning.booleanprefetchPositioningInfo(List<String> buildingIds, CommunicationConfig config, Handler<String> callback) Download all the necessary information to start positioning in the selected buildings.booleanprefetchPositioningInfo(List<String> buildingIds, Handler<String> callback) Download all the necessary information to start positioning in the selected buildings.booleanupdateOccurrence(EventOccurrence occurrence, EventAction action, Handler<EventOccurrence> callback) Update an event occurrence The time when the action was produced can be provided in theoccurrence; if not,new Date()is assumed.booleanupdateRailWidth(String building, float railWidth, Handler<Object> callback) Update the calibrations rail width for a buildingbooleanvalidateUserCredentials(Handler<Object> callback) Check if the user credentials previously set withConfiguration.setUserPass(String, String),SitumSdk.configuration()or in the AndroidManifest.xml are right.
-
Method Details
-
validateUserCredentials
Check if the user credentials previously set withConfiguration.setUserPass(String, String),SitumSdk.configuration()or in the AndroidManifest.xml are right.- Parameters:
callback- invoked when login is finished. If the user and/or password/api key aren't valid aCommunicationManager.Code.HTTP_UNAUTHORIZEDwill be received inHandler.onFailure(Error)- Returns:
- True if request is sent. False if request can't be sent: there is no user email and password.
-
fetchOrganizationTheme
Get organization theme: company name, logo and colors- Parameters:
callback- Callback to asynchronously receive the organization theme. Not null.- Returns:
- True if request is sent. False if request can't be sent:
-
logout
Ends the user session. The token is invalidated on the server and every credential the SDK holds is dropped, including the apikey or the email and password previously provided throughConfiguration.The SDK is left with no credentials at all, so it cannot obtain a new token by itself. To keep using it, provide credentials again with
Configuration.setApiKey(String),Configuration.setUserPass(String, String)orConfiguration.setToken(String). Until then every request fails withCommunicationManager.Code.HTTP_UNAUTHORIZED.Credentials are only dropped once the server confirms the logout. If the callback reports a failure, the session is still active and nothing has been removed.
- Parameters:
callback- invoked when logout is finished. Can be null.- Returns:
- always true: the request is sent unconditionally.
-
prefetchPositioningInfo
Download all the necessary information to start positioning. This includesBuilding,BuildingInfoand the building's model. Downloaded information will be saved in cache. Previous to version 2.50.2 the model was only obtained while starting positioning inside aBuilding- Parameters:
callback- Callback to asynchronously receive the result of this call. An error will be notified if anything fails during the download, only the most critical error will be sent
-
prefetchPositioningInfo
Download all the necessary information to start positioning. This includesBuilding,BuildingInfoand the building's model. Downloaded information will be saved in cache. Previous to version 2.50.2 the model was only obtained while starting positioning inside aBuilding- Parameters:
callback- Callback to asynchronously receive the result of this call. An error will be notified if anything fails during the download, only the most critical error will be sentconfig- request specific configuration. Can be null.
-
prefetchPositioningInfo
boolean prefetchPositioningInfo(@NonNull List<String> buildingIds, @NonNull Handler<String> callback) Download all the necessary information to start positioning in the selected buildings. This includesBuilding,BuildingInfoand the building's model. Downloaded information will be saved in cache. Previous to version 2.50.2 the model was only obtained while starting positioning inside aBuilding- Parameters:
buildingIds- List with the ids of the buildings you want to prefetchcallback- Callback to asynchronously receive the result of this call. An error will be notified if anything fails during the download, only the most critical error will be sent
-
prefetchPositioningInfo
boolean prefetchPositioningInfo(@NonNull List<String> buildingIds, CommunicationConfig config, Handler<String> callback) Download all the necessary information to start positioning in the selected buildings. This includesBuilding,BuildingInfoand the building's model. Downloaded information will be saved in cache. Previous to version 2.50.2 the model was only obtained while starting positioning inside aBuilding- Parameters:
buildingIds- List with the ids of the buildings you want to prefetchcallback- Callback to asynchronously receive the result of this call. An error will be notified if anything fails during the download, only the most critical error will be sentconfig- request specific configuration. Can be null.
-
fetchBuildings
Download all the buildings for the current user- Parameters:
callback- Callback to asynchronously receive the buildings. Not null.
-
fetchBuildings
Download all the buildings for the current user- Parameters:
config- request specific configuration. Can be null.callback- Callback to asynchronously receive the buildings. Not null.
-
fetchBuildingInfo
Download all the building data for the selected building. This info includes floors, indoor and outdoor POIs, events and paths. Also it download floor maps and POI category icons to local storage.- Parameters:
buildingId- selected building for download info. Not null.callback- Callback to asynchronously receive the buildings. Not null.
-
fetchBuildingInfo
boolean fetchBuildingInfo(@NonNull String buildingId, CommunicationConfig config, @NonNull Handler<BuildingInfo> callback) Download all the building data from the selected building. This info includes floors, indoor and outdoor POIs, events and paths. Also it download floor maps and POI category icons to local storage.- Parameters:
buildingId- selected building for download info. Not null.config- request specific configuration. Can be null.callback- Callback to asynchronously receive the buildings. Not null.
-
fetchFloorsFromBuilding
boolean fetchFloorsFromBuilding(@NonNull String buildingId, @NonNull Handler<Collection<Floor>> callback) Download all the floors of a building- Parameters:
buildingId- the building identifier. Not null.callback- Callback to asynchronously receive the floors. Not null.
-
fetchFloorsFromBuilding
boolean fetchFloorsFromBuilding(@NonNull String buildingId, CommunicationConfig config, @NonNull Handler<Collection<Floor>> callback) Download all the floors of a building- Parameters:
buildingId- the building identifier. Not null.config- request specific configuration. Can be null.callback- Callback to asynchronously receive the floors. Not null.
-
fetchTilesFromBuilding
Download the building Tiles. Not all the buildings have tiles available to be downloaded. If the tiles are available, a zip file is downloaded and unzipped in the internal storage.- Parameters:
buildingId-callback-
-
getTileFromBuilding
Returns a specific image tile for a building and floor combination. The tile could be a path to an internal storage, for the case that the tiles were previously fetched for a particular building or a URL to an online one in any other case.- Parameters:
buildingId-floorId-x-y-zoom-- Returns:
-
fetchMapFromFloor
Download the map image of a floor- Parameters:
floor- the floor. Not null.callback- callback to asynchronously receive the floor image. Not null.
-
fetchMapFromFloor
boolean fetchMapFromFloor(@NonNull Floor floor, CommunicationConfig config, @NonNull Handler<android.graphics.Bitmap> callback) Download the map image of a floor- Parameters:
floor- the floor. Not null.config- request specific configuration. Can be null.callback- callback to asynchronously receive the image. Not null.
-
fetchIndoorPOIsFromBuilding
boolean fetchIndoorPOIsFromBuilding(@NonNull String buildingId, @NonNull Handler<Collection<Poi>> callback) Download the indoor POIs of a building- Parameters:
buildingId- the building identifier. Not null.callback- Callback to asynchronously receive the points of interest. Not null.
-
fetchIndoorPOIsFromBuilding
boolean fetchIndoorPOIsFromBuilding(@NonNull String buildingId, CommunicationConfig config, @NonNull Handler<Collection<Poi>> callback) Download the indoor POIs of a building- Parameters:
buildingId- the building identifier. Not null.config- request specific configuration. Can be null.callback- callback to asynchronously receive the points of interest. Not null.
-
fetchClosestPOIs
boolean fetchClosestPOIs(@NonNull Location location, @Nullable String poiCategoryIdentifier, int limit, @Nullable es.situm.sdk.directions.DistanceAlgorithm distanceAlgorithm, @NonNull Handler<Collection<PoiWithDistance>> callback) Returns a list of indoor POIs ordered from closest to furthest with respect to the givenLocation. Internally, this method performs a network request to download all POIs and their categories for the building associated with the location, filters them by category, calculates their distances, and orders them. Important: The given location must be indoor, meaning it must include a valid building identifier. If not, thecallbackwill be triggered with an error. Note: You can filter the POIs by category specifying , limit the number of results with and set the distance calculation algorithm with .- Parameters:
location- - Non null. Indoor Location that will be taken as origin to calculate distances to the POIs.poiCategoryIdentifier- - Apply a PoiCategory filter to the POIs result. If null, we will calculate the distance to every POI of the building.limit- - Maximum number of POIs to return. If 0 all the POIs that satisfy the filter will be returned.distanceAlgorithm- - SeeDistanceAlgorithm. If null, defaults toDistanceAlgorithm.HAVERSINEcallback- - Non null. Handler that will receive either a Collection<PoiWithDistance> with the POIs ordered from closest to furthest, or an error during the fetch operation.- Throws:
IllegalArgumentException- is thrown in case or are null.
-
fetchIndoorPOIFromBuilding
boolean fetchIndoorPOIFromBuilding(@NonNull String poiId, @NonNull String buildingId, @NonNull Handler<Poi> callback) Download the given indoor POI of a building.- Parameters:
poiId- the POI identifier. Not null.buildingId- the building identifier. Not null.callback- callback to asynchronously receive the points of interest. Not null.- Returns:
-
fetchIndoorPOIFromBuilding
boolean fetchIndoorPOIFromBuilding(@NonNull String poiId, @NonNull String buildingId, CommunicationConfig config, @NonNull Handler<Poi> callback) Download the given indoor POI of a building.- Parameters:
poiId- the POI identifier. Not null.buildingId- the building identifier. Not null.config- request specific configuration. Can be null.callback- callback to asynchronously receive the points of interest. Not null.- Returns:
-
fetchAllPOIsFromUser
Download the POIs from all the buildings of the user- Parameters:
callback- callback to asynchronously receive the points of interest. Not null.
-
fetchAllPOIsFromUser
boolean fetchAllPOIsFromUser(CommunicationConfig config, @NonNull Handler<Collection<Poi>> callback) Download the POIs from all the buildings of the user- Parameters:
config- request specific configuration. Can be null.callback- callback to asynchronously receive the points of interest. Not null.
-
fetchPoiCategories
Get all POI categories, download and cache their icons asynchronouslyTo get category icons, use
fetchPoiCategoryIcon(PoiCategory, boolean, Handler).- Parameters:
callback- Callback to asynchronously receive the POI categories. Not null.
-
fetchPoiCategories
boolean fetchPoiCategories(CommunicationConfig config, @NonNull Handler<Collection<PoiCategory>> callback) Get all POI categories, download and cache their icons asynchronously.To get category icons, use
fetchPoiCategoryIcon(PoiCategory, boolean, Handler).- Parameters:
config- the request specific configuration. Can be null.callback- Callback to asynchronously receive the POI categories
-
fetchPoiCategoryIcon
boolean fetchPoiCategoryIcon(@NonNull PoiCategory category, boolean selected, @NonNull Handler<android.graphics.Bitmap> callback) Get the normal category icon for a category- Parameters:
category- the category. Not null.selected- fetch icon for selected or normal state.callback- the callback. Not null.
-
fetchPoiCategoryIcon
boolean fetchPoiCategoryIcon(@NonNull PoiCategory category, boolean selected, CommunicationConfig config, @NonNull Handler<android.graphics.Bitmap> callback) Get the normal category icon for a category- Parameters:
category- the category. Not null.selected- fetch icon for selected or normal state.config- the request specific configuration. Can be null.callback- the callback. Not null.
-
fetchOutdoorPOIsFromBuilding
boolean fetchOutdoorPOIsFromBuilding(@NonNull String buildingId, @NonNull Handler<Collection<Poi>> callback) Download the outdoor POIs of a building- Parameters:
buildingId- the building identifier. Not null.callback- Callback to asynchronously receive the points of interest. Not null.
-
fetchOutdoorPOIsFromBuilding
boolean fetchOutdoorPOIsFromBuilding(@NonNull String buildingId, CommunicationConfig config, @NonNull Handler<Collection<Poi>> callback) Download the outdoor POIs of a building- Parameters:
buildingId- the building identifier. Not null.config- requerst specific configuration. Can be null.callback- Callback to asynchronously receive the points of interest. Not null.
-
fetchEventsFromBuilding
boolean fetchEventsFromBuilding(@NonNull String buildingId, @NonNull Handler<Collection<SitumEvent>> callback) Download the events of a building- Parameters:
buildingId- the building identifier. Not null.callback- Callback to asynchronously receive the events of a building. Not null.
-
fetchEventsFromBuilding
boolean fetchEventsFromBuilding(@NonNull String buildingId, CommunicationConfig config, @NonNull Handler<Collection<SitumEvent>> callback) Download the events of a building- Parameters:
buildingId- the building identifier. Not null.config- request specific configuration. Can be null.callback- Callback to asynchronously receive the events of a building. Not null.
-
createOccurrenceForEvent
boolean createOccurrenceForEvent(@NonNull SitumEvent event, @NonNull Handler<EventOccurrence> callback) Create an occurrence for an event.- Parameters:
event- the event that occurred. Not null.callback- receives an event occurrence, necessary to notify a click and conversion of the same event. Not null.- See Also:
-
updateOccurrence
boolean updateOccurrence(@NonNull EventOccurrence occurrence, EventAction action, @NonNull Handler<EventOccurrence> callback) Update an event occurrence The time when the action was produced can be provided in theoccurrence; if not,new Date()is assumed.- Parameters:
occurrence- event occurrence. Not null. occurrence.getId() not null.action- action performed on the event.callback- receives the updated occurrence, necessary to notify a conversion of the same event. Not null.- See Also:
-
fetchGeofencesFromBuilding
boolean fetchGeofencesFromBuilding(@NonNull Building building, @NonNull Handler<List<Geofence>> callback) Get the geofences of a building- Parameters:
building- the building. Not null.callback- the callback. Not null.
-
fetchGeofencesFromBuilding
boolean fetchGeofencesFromBuilding(@NonNull Building building, CommunicationConfig config, @NonNull Handler<List<Geofence>> callback) Get the geofences of a building- Parameters:
building- the building. Not null.config- request specific configuration. Can be null.callback- the callback. Not null.
-
fetchRailWidth
Get the calibrations rail width used in a building- Parameters:
buildingId- the building identifier. Not nullcallback- the callback. Not null
-
updateRailWidth
boolean updateRailWidth(@NonNull String building, float railWidth, @NonNull Handler<Object> callback) Update the calibrations rail width for a building- Parameters:
building- the building identifier. Not nullrailWidth- the new rail widthcallback- the callback. Not null
-
fetchRemoteConfig
Get theRemoteConfigfor the current user.- Parameters:
callback- Callback to asynchronously receive the remote config. Not null.
-
fetchRemoteConfig
boolean fetchRemoteConfig(@NonNull LocationRequest locationRequest, @NonNull Handler<RemoteConfig> callback) Get theRemoteConfigfor the current user. The givenLocationRequestwill be used do override the remote location request.- Parameters:
locationRequest- Local location request used to override remote values. Not null.callback- Callback to asynchronously receive the remote config. Not null.
-
invalidateCache
void invalidateCache()Invalidate all the resources in the cache -
invalidateTiles
void invalidateTiles()Invalidate all tiles resources -
getHttpRequestExecutor
Return the HTTP Request Executor to make custom requests to the Dashboard
-