public class UniversiActivityDelegate extends UniversiContextDelegate
UniversiContextDelegate implementation that can be used within context of Activity.
Activity delegate has additional support for Fragments management via FragmentController.
Fragment controller can be accessed via getFragmentController() and custom controller can
be specified via setFragmentController(FragmentController). Fragment factory that provides
fragments to be displayed in a context of a specific UniversiActivity can be specified via
setFragmentFactory(FragmentFactory).
Navigational transition that can be specified via setNavigationalTransition(BaseNavigationalTransition)
can be used to finish the associated activity.
Note that this class has not been made final on purpose so it may be easily mocked in tests, thought it should not been extended.
UniversiFragmentDelegate| Modifier and Type | Method and Description |
|---|---|
static UniversiActivityDelegate |
create(Activity activity)
Creates a new instance of UniversiActivityDelegate for the given activity.
|
void |
destroyLoader(int id)
Destroys a loader with the specified id.
|
Fragment |
findCurrentFragment()
Searches for current fragment displayed in container that is used by
FragmentController
of this delegate to show fragments in the context of the associated activity. |
boolean |
finishWithNavigationalTransition()
Finishes the associated activity with navigational transition specified via
setNavigationalTransition(BaseNavigationalTransition) (if any). |
FragmentController |
getFragmentController()
Returns the default controller or the one specified via
setFragmentController(FragmentController)
that is used to manage fragments of the associated activity. |
FragmentFactory |
getFragmentFactory()
Returns the factory providing fragment instances for fragment controller of this delegate.
|
BaseNavigationalTransition |
getNavigationalTransition()
Returns the navigational transition used to finish associated activity via
finishWithNavigationalTransition(). |
<D> Loader<D> |
initLoader(int id,
Bundle params,
LoaderManager.LoaderCallbacks<D> callbacks)
Initializes a loader with the specified id for the given callbacks.
|
boolean |
popFragmentsBackStack()
Pops stack with fragments of the associated activity via
FragmentManager.popBackStack() |
<D> Loader<D> |
restartLoader(int id,
Bundle params,
LoaderManager.LoaderCallbacks<D> callbacks)
Re-starts a loader with the specified id for the given callbacks.
|
void |
setFragmentController(FragmentController controller)
Sets a controller used to manage (show/hide) fragments in context of the associated activity.
|
void |
setFragmentFactory(FragmentFactory factory)
Sets a factory that provides fragment instances for fragment controller of this delegate.
|
void |
setNavigationalTransition(BaseNavigationalTransition transition)
Sets a navigational transition that can be used to finish associated activity via
finishWithNavigationalTransition(). |
<D> Loader<D> |
startLoader(int id,
Bundle params,
LoaderManager.LoaderCallbacks<D> callbacks)
Starts a loader with the specified id.
|
create, dismissDialogWithId, dismissXmlDialog, getDialogController, getDialogFactory, isActiveNetworkConnected, isNetworkConnected, isPaused, isRequestRegistered, isViewCreated, registerRequest, setDialogController, setDialogFactory, setDialogXmlFactory, setPaused, setViewCreated, showDialogWithId, showXmlDialog, unregisterRequest@NonNull public static UniversiActivityDelegate create(@NonNull Activity activity)
activity - The activity context in which will be the new delegate used.@Nullable public <D> Loader<D> startLoader(int id, @Nullable Bundle params, @NonNull LoaderManager.LoaderCallbacks<D> callbacks)
id - Id of the desired loader to start.params - Params for loader.callbacks - Callbacks for loader.null if the specified callbacks
do not create loader for the specified id.initLoader(int, Bundle, LoaderManager.LoaderCallbacks),
restartLoader(int, Bundle, LoaderManager.LoaderCallbacks),
destroyLoader(int)@Nullable public <D> Loader<D> initLoader(int id, @Nullable Bundle params, @NonNull LoaderManager.LoaderCallbacks<D> callbacks)
id - Id of the desired loader to init.params - Params for loader.callbacks - Callbacks for loader.null if the specified callbacks do
not create loader for the specified id.startLoader(int, Bundle, LoaderManager.LoaderCallbacks),
restartLoader(int, Bundle, LoaderManager.LoaderCallbacks),
destroyLoader(int),
LoaderManager.initLoader(int, Bundle, LoaderManager.LoaderCallbacks)@Nullable public <D> Loader<D> restartLoader(int id, @Nullable Bundle params, @NonNull LoaderManager.LoaderCallbacks<D> callbacks)
id - Id of the desired loader to re-start.params - Params for loader.callbacks - Callbacks for loader.null if the specified callbacks do
not create loader for the specified id.startLoader(int, Bundle, LoaderManager.LoaderCallbacks),
initLoader(int, Bundle, LoaderManager.LoaderCallbacks),
destroyLoader(int),
LoaderManager.restartLoader(int, Bundle, LoaderManager.LoaderCallbacks)public void destroyLoader(int id)
id - Id of the desired loader to destroy.initLoader(int, Bundle, LoaderManager.LoaderCallbacks),
restartLoader(int, Bundle, LoaderManager.LoaderCallbacks),
LoaderManager.destroyLoader(int)public void setNavigationalTransition(@Nullable BaseNavigationalTransition transition)
finishWithNavigationalTransition().
If the given transition is not null this method will also configure incoming transitions
for the associated activity via BaseNavigationalTransition.configureIncomingTransitions(Activity).
transition - The desired transition. May be null to clear the current one.getNavigationalTransition()@Nullable public BaseNavigationalTransition getNavigationalTransition()
finishWithNavigationalTransition().null if no transition has been specified.setNavigationalTransition(BaseNavigationalTransition)public boolean finishWithNavigationalTransition()
setNavigationalTransition(BaseNavigationalTransition) (if any).True if transition has been started, false otherwise.public void setFragmentController(@Nullable FragmentController controller)
controller - The desired controller. May be null to use the default one.getFragmentController(),
setFragmentFactory(FragmentFactory)@NonNull public FragmentController getFragmentController()
setFragmentController(FragmentController)
that is used to manage fragments of the associated activity.public void setFragmentFactory(@Nullable FragmentFactory factory)
factory - The desired factory. May be null to clear the current one.setFragmentController(FragmentController),
getFragmentController(),
getFragmentFactory()@Nullable public FragmentFactory getFragmentFactory()
null if no factory has been specified.setFragmentFactory(FragmentFactory)@Nullable public Fragment findCurrentFragment()
FragmentController
of this delegate to show fragments in the context of the associated activity.FragmentController.findCurrentFragment()
or null if there is no fragment displayed.public boolean popFragmentsBackStack()
FragmentManager.popBackStack()True if the stack has ben popped, false otherwise.