use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.
the class AbstractSmvpDialogFragment 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 AbstractSmvpFragment 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 AbstractUiActivity 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 contractBrokerKey = savedState.getString(STATE_CONTRACT_BROKER);
if (contractBrokerKey != null) {
contractBroker = objectRegistry.get(contractBrokerKey);
}
return contractBroker;
}
use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.
the class AbstractUiFragment 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 AbstractPreservableActivity method onSaveInstanceState.
// endregion
// region Android lifecycle
@CallSuper
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
ObjectRegistry objectRegistry = getObjectRegistry();
outState.putString(STATE_PRESERVATION_MANAGER_KEY, objectRegistry.put(mStatePreservationManager));
}
Aggregations