use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.
the class AbstractPreservableFragment method restoreViewStateManager.
// endregion
// region Private helper methods
private StatePreservationManager restoreViewStateManager(Bundle savedState) {
StatePreservationManager statePreservationManager = null;
ObjectRegistry objectRegistry = getObjectRegistry();
String statePreservationHandlerKey = savedState.getString(STATE_PRESERVATION_MANAGER_KEY);
if (statePreservationHandlerKey != null) {
statePreservationManager = objectRegistry.get(statePreservationHandlerKey);
}
return statePreservationManager;
}
use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.
the class AbstractSmvpDialogFragment method restorePresenterStack.
/**
* Attempt to restore and update a saved presenter and model stack. Returns the updated stack if successful or a
* newly created and initialized one if failed to restore.
*/
@NonNull
private PresenterT restorePresenterStack(Bundle savedInstanceState) {
PresenterT presenter = null;
// Obtain the object registry key from the saved instance bundle
String presenterKey = savedInstanceState.getString(SAVED_PRESENTER_STACK_KEY);
// If we got one, attempt to restore from the object registry
if (presenterKey != null) {
ObjectRegistry objectRegistry = getObjectRegistry();
presenter = objectRegistry.get(presenterKey);
}
if (presenter != null) {
// If we got a restored presenter & model stack, ask for a model updater
ModelEstablisher<ModelT> modelUpdater = createModelUpdater(savedInstanceState);
// Ask the presenter to call the updater if it exists.
if (modelUpdater != null) {
presenter.onInitializeModel(modelUpdater);
}
// Ask the presenter to update itself
presenter.onUpdate();
} else {
// If we failed to update, create an initialize a new presenter and model stack.
presenter = createPresenterStack();
}
return presenter;
}
use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.
the class AbstractSmvpFragment method onSaveInstanceState.
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
// Save the Presenter & Model stack.
ObjectRegistry objectRegistry = getObjectRegistry();
String presenterStackKey = objectRegistry.put(getPresenter());
outState.putString(SAVED_PRESENTER_STACK_KEY, presenterStackKey);
}
use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.
the class AbstractUiActivity method onSaveInstanceState.
// endregion
// region Android lifecycle
@CallSuper
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
ObjectRegistry objectRegistry = getObjectRegistry();
outState.putString(STATE_CONTRACT_BROKER, objectRegistry.put(mContractBroker));
}
use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.
the class AbstractUiDialogFragment method restoreContractBroker.
// endregion
// region private helper methods
private ContractBroker<UiT, NavigationT, CoordinatorT, StateManagerT> restoreContractBroker(Bundle savedState) {
ContractBroker<UiT, NavigationT, CoordinatorT, StateManagerT> contractBroker = null;
ObjectRegistry objectRegistry = getObjectRegistry();
String coordinatorKey = savedState.getString(STATE_CONTRACT_BROKER);
if (coordinatorKey != null) {
contractBroker = objectRegistry.get(coordinatorKey);
}
return contractBroker;
}
Aggregations