Package zendesk.core
Interface ActionHandler
-
- All Known Implementing Classes:
- CreateRequestActionHandler
public interface ActionHandler
Defines a handler for an inter-SDK action, such as one SDK starting another one, without either SDK having a dependency on the other. An example of this would be a hypothetical Help Center SDK starting the "create ticket" screen of the Support SDK.In order to properly separate SDKs from each other, handlers will work on "action Strings". Similar to Android's Intent system, multiple SDKs can be capable of handling the same action String. For example, a "contact us" action can be handled by Support, Chat, Voice, Message, etc. In the event that more than one ActionHandler has been registered for the same actionString, the
getPriority()
method can be used to determine which one to callhandle
on.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description boolean
canHandle(java.lang.String actionName)
Determines whether or not the ActionHandler object can handle the given action String.ActionDescription
getActionDescription()
int
getPriority()
Returns the priority of the ActionHandler.void
handle(java.util.Map<java.lang.String,java.lang.Object> data, Context context)
Invokes an action on the given action String.void
updateSettings(java.util.Map<java.lang.String,JsonElement> settings)
Notifies the ActionHandler of an update to settings.
-
-
-
Method Detail
-
canHandle
boolean canHandle(java.lang.String actionName)
Determines whether or not the ActionHandler object can handle the given action String.- Parameters:
actionName
- the action String to check against.- Returns:
- true if the action String can be handled, false if it can't.
-
handle
void handle(java.util.Map<java.lang.String,java.lang.Object> data, Context context)
Invokes an action on the given action String. This is expected to be the starting of an Activity, hence theContext
parameter.This method can be called before init for a given SDK is performed so you need to check if any SDK's called here are initialised before any action takes place.
- Parameters:
data
- an optional map of key-value pairs for theActionHandler
to use in handling the action.context
- theContext
to use in invoking the action, such as starting an Activity.
-
getPriority
int getPriority()
Returns the priority of the ActionHandler. The higher the number, the higher the priority.- Returns:
- the priority of the ActionHandler.
-
getActionDescription
ActionDescription getActionDescription()
- Returns:
- a description for this action.
-
updateSettings
void updateSettings(java.util.Map<java.lang.String,JsonElement> settings)
Notifies the ActionHandler of an update to settings. These settings allows the ActionHandler to determine whether they should be enabled. This will contain settings for each of the SDKs enabled for this account. Each ActionHandler should extract the settings object relating to its specific SDK and only store that.- Parameters:
settings
- a map representing the SDK settings for the current instance.
-
-