Search in sources :

Example 6 with ObjectRegistry

use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.

the class AbstractPreservableDialogFragment 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)

Example 7 with ObjectRegistry

use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.

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

Example 8 with ObjectRegistry

use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.

the class AbstractSmvpActivity 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 9 with ObjectRegistry

use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.

the class AbstractPreservableActivity method restoreViewStateManager.

// endregion
// region private helper methods
private StatePreservationManager restoreViewStateManager(Bundle savedState) {
    StatePreservationManager uiStatePreservationManager = null;
    ObjectRegistry objectRegistry = getObjectRegistry();
    String statePreservationHandlerKey = savedState.getString(STATE_PRESERVATION_MANAGER_KEY);
    if (statePreservationHandlerKey != null) {
        uiStatePreservationManager = objectRegistry.get(statePreservationHandlerKey);
    }
    return uiStatePreservationManager;
}
Also used : StatePreservationManager(com.cjsoftware.library.uistatepreservation.StatePreservationManager) ObjectRegistry(com.cjsoftware.library.core.ObjectRegistry)

Example 10 with ObjectRegistry

use of com.cjsoftware.library.core.ObjectRegistry in project ucsFramework by cjsoftware-lib.

the class AbstractPreservableFragment 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