Package zendesk.core
Interface NetworkInfoProvider
-
public interface NetworkInfoProviderA provider which will provide information about network connectivity.It must be registered (using the
NetworkInfoProvider.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 the
NetworkInfoProvider.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 adding
NetworkAwarelisteners to be notified when the network state changes.It also allows for adding
RetryActionobjects, which will be next time a network becomes available.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description voidaddNetworkAwareListener(java.lang.Integer id, NetworkAware listener)Add aNetworkAwarelistener object, which will receive updates to the network state viaNetworkAware.onNetworkAvailable()andNetworkAware.onNetworkUnavailable()as long as theNetworkInfoProvideris currently in a registered state.voidaddRetryAction(java.lang.Integer id, RetryAction retryAction)Add aRetryAction, whoseRetryAction.onRetry()method will be called the next time the provider is notified with network availability.voidclearNetworkAwareListeners()Clear all addedNetworkAwarelistener objects.voidclearRetryActions()Clear all addedRetryActionobjects.booleanisNetworkAvailable()Returns whether or not the network is currently available.voidregister()Begin listening for network change events.voidremoveNetworkAwareListener(java.lang.Integer id)Remove aNetworkAwarelistener object so that it will no longer receive updates to network state.voidremoveRetryAction(java.lang.Integer id)Remove aRetryActionso that it will not be invoked next time the provider is notified with network availability.voidunregister()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 aNetworkAwarelistener object, which will receive updates to the network state viaNetworkAware.onNetworkAvailable()andNetworkAware.onNetworkUnavailable()as long as theNetworkInfoProvideris currently in a registered state. TheNetworkAwarewill 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- theNetworkAwarelistener object to be notified of network change events.
-
removeNetworkAwareListener
void removeNetworkAwareListener(java.lang.Integer id)
Remove aNetworkAwarelistener object so that it will no longer receive updates to network state.- Parameters:
id- the ID for theNetworkAwarelistener object to stop notifying.
-
clearNetworkAwareListeners
void clearNetworkAwareListeners()
Clear all addedNetworkAwarelistener objects. AnyNetworkAwarelisteners 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, theRetryActionis removed from the list and will not be invoked again. TheRetryActionwill 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 theRetryActioninNetworkInfoProvider.removeRetryAction(Integer)retryAction- theRetryActionto invoke and remove, the next time the provider receives a positive network availability update.
-
removeRetryAction
void removeRetryAction(java.lang.Integer id)
Remove aRetryActionso that it will not be invoked next time the provider is notified with network availability.- Parameters:
id- the ID for theRetryActionto remove.
-
clearRetryActions
void clearRetryActions()
Clear all addedRetryActionobjects. AnyRetryActionlisteners previously added will no longer be invoked after this method has been called, unless they are added again via
-
-