-
public class RuntimeManagerManager that contains library state and locks
-
-
Field Summary
Fields Modifier and Type Field Description private Contextcontextprivate DatelastUserStartDateprivate Activityactivityprivate SessionManagersessionManager
-
Constructor Summary
Constructors Constructor Description RuntimeManager()Constructor
-
Method Summary
Modifier and Type Method Description ContextgetContext()Get the context voidsetContext(Context context)Set the context, you should NEVER call this method outside of a changeState methodThis method is NOT thread safe DategetLastUserStartDate()Get the last time Batch was started for user activity. ActivitygetActivity()Get the activity voidsetActivity(Activity activity)Set the activity, you should NEVER call this method outside of a changeState methodThis method is NOT thread safe SessionManagergetSessionManager()voidreadConfig(@NonNull() ConfigAction action)Execute an action to read the batch configurationYou should never use this method to update the configuration. voidupdateConfig(@NonNull() ConfigAction action)Execute an action to update the batch configuration.Configuration can only be update if the sdk is not started. booleanchangeState(ChangeStateAction action)Execute an action to modify the state booleanchangeStateIf(State wantedState, ChangeStateAction action)Execute an action to modify the state if the current state equals the wanted one voidrun(StateAction action)Execute an action with read lock voidrunIf(State wantedState, StateAction action)Execute an action with read lock if the current state equals the wanted state booleanrunIfReady(Runnable action)Run this action if Batch is ready booleanrunIf(State wantedState, Runnable action)Run this action if Batch is at the given wanted state LongonStart()Method to call when onStart is called to get the last stop timestamp (if any)This method is NOT thread safe, should only be called on a changeState method voidonStopWithoutFinishing()Method to call when onStop is called without a finishing activityThis method is NOT thread safe, should only be called on a changeState method voidincrementServiceRefCount()Increment the number of calls to onServiceCreate registered voiddecrementServiceRefCount()Decrement the number of services retaining Batch. voidresetServiceRefCount()Forces the service ref count to be zeroDangerous booleanisReady()Checks if Batch is ready booleanisRetainedByService()Checks if the service's refcount is greater than 0 voidupdateLastUserStartDate()Set the last time the Batch was started for user activity to now. voidregisterActivityListenerIfNeeded(@NonNull() Application application)booleanisApplicationInForeground()voidregisterSessionManagerIfNeeded(@NonNull() Application application, boolean simulateActivityStart)StringgetSessionIdentifier()-
-
Method Detail
-
getContext
@Nullable() Context getContext()
Get the context
-
setContext
void setContext(Context context)
Set the context, you should NEVER call this method outside of a changeState methodThis method is NOT thread safe
- Parameters:
context- Android's context
-
getLastUserStartDate
Date getLastUserStartDate()
Get the last time Batch was started for user activity.
-
getActivity
Activity getActivity()
Get the activity
-
setActivity
void setActivity(Activity activity)
Set the activity, you should NEVER call this method outside of a changeState methodThis method is NOT thread safe
- Parameters:
activity- Android's activity
-
getSessionManager
SessionManager getSessionManager()
-
readConfig
void readConfig(@NonNull() ConfigAction action)
Execute an action to read the batch configurationYou should never use this method to update the configuration.To do that use updateConfig
- Parameters:
action- action that will read the config.
-
updateConfig
void updateConfig(@NonNull() ConfigAction action)
Execute an action to update the batch configuration.Configuration can only be update if the sdk is not started.
- Parameters:
action- action that will modify the config
-
changeState
boolean changeState(ChangeStateAction action)
Execute an action to modify the state
- Parameters:
action- action that will modify the given state
-
changeStateIf
boolean changeStateIf(State wantedState, ChangeStateAction action)
Execute an action to modify the state if the current state equals the wanted one
- Parameters:
wantedState- The state we wantaction- The action to modify the state
-
run
void run(StateAction action)
Execute an action with read lock
- Parameters:
action- action that can read the given state
-
runIf
void runIf(State wantedState, StateAction action)
Execute an action with read lock if the current state equals the wanted state
- Parameters:
wantedState- The state we wantaction- The action to to read state
-
runIfReady
boolean runIfReady(Runnable action)
Run this action if Batch is ready
- Parameters:
action- The action to
-
runIf
boolean runIf(State wantedState, Runnable action)
Run this action if Batch is at the given wanted state
- Parameters:
wantedState- The state we wantaction- The action to run
-
onStart
Long onStart()
Method to call when onStart is called to get the last stop timestamp (if any)This method is NOT thread safe, should only be called on a changeState method
-
onStopWithoutFinishing
void onStopWithoutFinishing()
Method to call when onStop is called without a finishing activityThis method is NOT thread safe, should only be called on a changeState method
-
incrementServiceRefCount
void incrementServiceRefCount()
Increment the number of calls to onServiceCreate registered
-
decrementServiceRefCount
void decrementServiceRefCount()
Decrement the number of services retaining Batch.
-
resetServiceRefCount
void resetServiceRefCount()
Forces the service ref count to be zeroDangerous
-
isReady
boolean isReady()
Checks if Batch is ready
-
isRetainedByService
boolean isRetainedByService()
Checks if the service's refcount is greater than 0
-
updateLastUserStartDate
void updateLastUserStartDate()
Set the last time the Batch was started for user activity to now.You should NEVER call this method outside of a changeState methodThis method is NOT thread safe
-
registerActivityListenerIfNeeded
void registerActivityListenerIfNeeded(@NonNull() Application application)
-
isApplicationInForeground
boolean isApplicationInForeground()
-
registerSessionManagerIfNeeded
void registerSessionManagerIfNeeded(@NonNull() Application application, boolean simulateActivityStart)
-
getSessionIdentifier
String getSessionIdentifier()
-
-
-
-