Search in sources :

Example 1 with ObjectRegistry

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);
}
Also used : ObjectRegistry(com.cjsoftware.library.core.ObjectRegistry)

Example 2 with ObjectRegistry

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;
}
Also used : ObjectRegistry(com.cjsoftware.library.core.ObjectRegistry) NonNull(android.support.annotation.NonNull)

Example 3 with ObjectRegistry

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;
}
Also used : ObjectRegistry(com.cjsoftware.library.core.ObjectRegistry)

Example 4 with ObjectRegistry

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));
}
Also used : ObjectRegistry(com.cjsoftware.library.core.ObjectRegistry) CallSuper(android.support.annotation.CallSuper)

Example 5 with ObjectRegistry

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));
}
Also used : ObjectRegistry(com.cjsoftware.library.core.ObjectRegistry) CallSuper(android.support.annotation.CallSuper)

Aggregations

ObjectRegistry (com.cjsoftware.library.core.ObjectRegistry)18 CallSuper (android.support.annotation.CallSuper)6 NonNull (android.support.annotation.NonNull)3 StatePreservationManager (com.cjsoftware.library.uistatepreservation.StatePreservationManager)3