package com.mobify.astro.plugins;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;

public interface NavigationStackFrame {

    /**
     * @return the container view for this frame
     */
    View getView();

    /**
     * Save the state of the view and destroy it. This can be undone later with
     * restoreInactiveViewFromSave().
     */
    void saveAndDestroyView();

    /**
     * Restores the view from a previously saved state if needed. The view must
     * have been previously saved and destroyed (i.e. with saveAndDestroyView())
     * otherwise this is a no-op.
     */
    void restoreInactiveViewFromSave();

    /**
     * Saves the view's state to the supplied bundle. The view is not destroyed.
     * @param bundle to save the state to
     */
    void saveStateToBundle(Bundle bundle);

    /**
     * Restores the view's state from the supplied bundle. If the view has been destroyed (is null)
     * we will not recreate the view and this is a no-op.
     * @param bundle to restore the state from
     */
    void restoreStateFromBundle(Bundle bundle);

    /**
     * @return true if frame has a currently active (not previously saved + destroyed) view
     */
    boolean hasActiveView();

    /**
     * @return true if frame has a currently active (non-null) webView
     */
    @Deprecated
    boolean hasWebView();

    /**
     * reload the current view
     */
    void reload();

    /**
     * @return a URL representation of the current frame
     */
    String getUrl();

    void setNavigationHost(NavigationHost host);

    /**
     * Destroy the frame
     */
    void destroyFrame();
}
