Package zendesk.core
Interface NetworkInfoProvider
-
public interface NetworkInfoProvider
A provider which will provide information about network connectivity. It must be registered (using theNetworkInfoProvider.register()
method) to begin listening for network changes, and unregistering (using theNetworkInfoProvider.unregister()
method) will stop it from receiving any more network changes. No changes will be received before theNetworkInfoProvider.register()
method has been called, or after theNetworkInfoProvider.unregister()
method has been called. It provides a simple synchronous method, isNetworkAvailable, which returns a boolean, as well as an interface for addingNetworkAware
listeners to be notified when the network state changes. It also allows for addingRetryAction
objects, which will be next time a network becomes available.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description void
addNetworkAwareListener(java.lang.Integer id, NetworkAware listener)
Add aNetworkAware
listener object, which will receive updates to the network state viaNetworkAware.onNetworkAvailable()
andNetworkAware.onNetworkUnavailable()
as long as theNetworkInfoProvider
is currently in a registered state.void
addRetryAction(java.lang.Integer id, RetryAction retryAction)
Add aRetryAction
, whoseRetryAction.onRetry()
method will be called the next time the provider is notified with network availability.void
clearNetworkAwareListeners()
Clear all addedNetworkAware
listener objects.void
clearRetryActions()
Clear all addedRetryAction
objects.boolean
isNetworkAvailable()
Returns whether or not the network is currently available.void
register()
Begin listening for network change events.void
removeNetworkAwareListener(java.lang.Integer id)
Remove aNetworkAware
listener object so that it will no longer receive updates to network state.void
removeRetryAction(java.lang.Integer id)
Remove aRetryAction
so that it will not be invoked next time the provider is notified with network availability.void
unregister()
Stop listening for network change events.
-
-
-
Method Detail
-
register
void register()
Begin listening for network change events.
-
unregister
void unregister()
Stop listening for network change events.
-
isNetworkAvailable
boolean isNetworkAvailable()
Returns whether or not the network is currently available.- Returns:
- true if the network is currently available, false if not.
-
addNetworkAwareListener
void addNetworkAwareListener(java.lang.Integer id, NetworkAware listener)
Add aNetworkAware
listener object, which will receive updates to the network state viaNetworkAware.onNetworkAvailable()
andNetworkAware.onNetworkUnavailable()
as long as theNetworkInfoProvider
is currently in a registered state. TheNetworkAware
will continue to receive updates as the network availability changes until either it is removed, or theNetworkInfoProvider.unregister()
method is called.- Parameters:
id
- the ID to use for this listener. The same ID should be used when removing the listener inNetworkInfoProvider.removeNetworkAwareListener(Integer)
listener
- theNetworkAware
listener object to be notified of network change events.
-
removeNetworkAwareListener
void removeNetworkAwareListener(java.lang.Integer id)
Remove aNetworkAware
listener object so that it will no longer receive updates to network state.- Parameters:
id
- the ID for theNetworkAware
listener object to stop notifying.
-
clearNetworkAwareListeners
void clearNetworkAwareListeners()
Clear all addedNetworkAware
listener objects. AnyNetworkAware
listeners previously added will no longer receive updates after this method is called, unless they are added again viaNetworkInfoProvider.addNetworkAwareListener(Integer, NetworkAware)
.
-
addRetryAction
void addRetryAction(java.lang.Integer id, RetryAction retryAction)
Add aRetryAction
, whoseRetryAction.onRetry()
method will be called the next time the provider is notified with network availability. After being invoked, theRetryAction
is removed from the list and will not be invoked again. TheRetryAction
will only be invoked if the provider is currently in a registered state.- Parameters:
id
- the ID to use for thisRetryAction
. The same ID should be used when removing theRetryAction
inNetworkInfoProvider.removeRetryAction(Integer)
retryAction
- theRetryAction
to invoke and remove, the next time the provider receives a positive network availability update.
-
removeRetryAction
void removeRetryAction(java.lang.Integer id)
Remove aRetryAction
so that it will not be invoked next time the provider is notified with network availability.- Parameters:
id
- the ID for theRetryAction
to remove.
-
clearRetryActions
void clearRetryActions()
Clear all addedRetryAction
objects. AnyRetryAction
listeners previously added will no longer be invoked after this method has been called, unless they are added again via
-
-