public abstract class UniversiContextDelegate extends Object
UniversiActivity, UniversiCompatActivity
and UniversiActivity to provide features in unified 'fashion' regardless of context in
which are these features supported.
A the current version this context delegate supports features described below:
DialogFragments managementDialogController. This controller can be accessed via
getDialogController() and custom controller can be specified via setDialogController(DialogController).
Without any set up this delegate can be used to show any implementation of XmlDialog via
showXmlDialog(int, DialogOptions) where for such case will be created internal instance
of DialogXmlFactory used to inflate such dialogs from an Xml file containing a
single dialog entry.
If the associated context wants to display XmlDialogs from an Xml file containing a
set of multiple dialog entries or just simple dialogs instantiated via plain Java code it
need to set instance of DialogFactory that can provide that dialogs
via setDialogFactory(DialogFactory). Such dialogs can be than displayed
via showDialogWithId(int, DialogOptions).
Already showing dialogs can be dismissed via dismissDialogWithId(int) or dismissXmlDialog(int).
If the associated context is paused (indicated via setPaused(boolean)), invoking one of
showDialog(...) methods will be ignored.
isActiveNetworkConnected()
or for a specific connection type via isNetworkConnected(int) for that matter.| Modifier and Type | Method and Description |
|---|---|
boolean |
dismissDialogWithId(int dialogId)
Dismisses a dialog that is provided by the current dialog factory under the specified dialogId.
|
boolean |
dismissXmlDialog(int resId)
Dismisses an Xml dialog that has been shown via
showXmlDialog(int, DialogOptions). |
DialogController |
getDialogController()
Returns the controller that can be used to show and dismiss dialogs within context that uses
this delegate
|
DialogFactory |
getDialogFactory()
Returns the current dialog factory specified for this delegate.
|
boolean |
isActiveNetworkConnected()
Checks whether the current active network is at this time connected or not.
|
boolean |
isNetworkConnected(int networkType)
Checks whether a network with the specified networkType is at this time connected
or no.
|
boolean |
isPaused()
Returns the boolean flag indicating whether the related context is paused or not.
|
boolean |
isRequestRegistered(int requestFlag)
Checks whether a request with the specified request flag is registered or not.
|
boolean |
isStateSaved()
Returns the boolean flag indicating whether state of the associated context has been already
saved or not.
|
boolean |
isViewCreated()
Returns the boolean flag indicating whether view hierarchy of the associated context is created
or not.
|
void |
registerRequest(int requestFlag)
Adds a request with the specified request flag into the registered ones.
|
void |
setDialogController(DialogController controller)
Sets a controller that should be used to show and dismiss dialogs within context that uses
this delegate.
|
void |
setDialogFactory(DialogFactory factory)
Specifies a factory that should provide dialog instances for
DialogController of
this delegate. |
void |
setDialogXmlFactory(int xmlDialogsSet)
Same as
setDialogFactory(DialogFactory) where will be passed instance of
DialogXmlFactory with the specified xmlDialogsSet. |
void |
setPaused(boolean paused)
Sets a boolean flag indicating whether the associated context has been paused or not.
|
void |
setStateSaved(boolean saved)
Sets a boolean flag indicating whether state of the associated context has been saved or not.
|
void |
setViewCreated(boolean created)
Sets a boolean flag indicating whether a view hierarchy of the associated context is created or not.
|
boolean |
showDialogWithId(int dialogId,
DialogOptions options)
Shows a dialog that is provided by the current dialog factory under the specified dialogId.
|
boolean |
showXmlDialog(int resId,
DialogOptions options)
Like
showDialogWithId(int, DialogOptions), but in this case will be used internal
instance of DialogXmlFactory to create (inflate) the desired dialog instance to be
shown. |
void |
unregisterRequest(int requestFlag)
Removes request with the specified request flag from the registered ones.
|
public void setDialogController(@Nullable
DialogController controller)
controller - The desired controller. May be null to use the default one.getDialogController()@NonNull public DialogController getDialogController()
If not specified, instance of DialogController is instantiated by default.
setDialogController(DialogController)public void setDialogXmlFactory(@XmlRes
int xmlDialogsSet)
setDialogFactory(DialogFactory) where will be passed instance of
DialogXmlFactory with the specified xmlDialogsSet.xmlDialogsSet - Resource id of the desired Xml file containing Xml dialogs that the
factory should provide. May be 0 to remove the current one.public void setDialogFactory(@Nullable
DialogFactory factory)
DialogController of
this delegate.factory - The desired factory. May be null to remove the current one.getDialogFactory(),
showDialogWithId(int, DialogOptions)@Nullable public DialogFactory getDialogFactory()
null if no factory has been specified yet.setDialogFactory(DialogFactory)public boolean showDialogWithId(int dialogId,
@Nullable
DialogOptions options)
dialogId - Id of the desired dialog to show.options - Options for the dialog.True if dialog has been shown, false if context that uses this delegate
is currently paused or its state has been already saved or does not have its dialog
factory specified.DialogController.newRequest(int),
setDialogFactory(DialogFactory),
dismissDialogWithId(int)public boolean dismissDialogWithId(int dialogId)
dialogId - Id of the desired dialog to dismiss.True if dialog has been dismissed, false if context that uses this
delegate is currently paused or does not have its dialog factory specified.DialogController.newRequest(int),
showDialogWithId(int, DialogOptions)public boolean showXmlDialog(@XmlRes
int resId,
@Nullable
DialogOptions options)
showDialogWithId(int, DialogOptions), but in this case will be used internal
instance of DialogXmlFactory to create (inflate) the desired dialog instance to be
shown.resId - Resource id of Xml file containing the desired dialog (its specification) to show.options - Options for the dialog.True if dialog has been successfully inflated and shown, false if
context that uses this delegate is currently paused or its state has been already saved
or dialog failed to be inflated.DialogXmlFactory.createDialog(int, DialogOptions),
dismissXmlDialog(int)public boolean dismissXmlDialog(@XmlRes
int resId)
showXmlDialog(int, DialogOptions).resId - Resource id of Xml file containing the desired dialog (its specification) to dismiss.True if dialog has been dismissed, false if context that uses this
delegate is currently paused.showXmlDialog(int, DialogOptions)public boolean isActiveNetworkConnected()
True if active network is connected, false otherwise.ConnectivityManager.getActiveNetworkInfo(),
NetworkInfo.isConnected(),
isNetworkConnected(int)public boolean isNetworkConnected(int networkType)
networkType - The desired network type to check for connection.True if the requested network is connected, false otherwise.ConnectivityManager.getNetworkInfo(int),
NetworkInfo.isConnected()public void setViewCreated(boolean created)
created - True if view hierarchy is created, false otherwise.isViewCreated()public boolean isViewCreated()
True if view is created, false otherwise.setViewCreated(boolean)public void setStateSaved(boolean saved)
saved - True if state has been saved, false otherwise.isStateSaved()public boolean isStateSaved()
This should be true after state of context is saved and before that context is resumed.
True if state has been saved, false otherwise.setStateSaved(boolean)public void setPaused(boolean paused)
paused - True if context is paused, false otherwise.()public boolean isPaused()
This should be true after context is paused and before it is again resumed.
True if context is paused, false otherwise.setPaused(boolean)public void registerRequest(int requestFlag)
requestFlag - The request flag that should be registered.isRequestRegistered(int),
unregisterRequest(int)public void unregisterRequest(int requestFlag)
requestFlag - The request flag that should be unregistered.registerRequest(int),
isRequestRegistered(int)public boolean isRequestRegistered(int requestFlag)
requestFlag - The request flag for which to check if it is registered.True if request is registered, false otherwise.registerRequest(int),
unregisterRequest(int)