package com.xg.navigation.debug;

public class DebugStackManager {
    /**
     * Dont display stack view.
     */
    public static final int NONE = 0;
    /**
     * Shake it to display stack view.
     */
    public static final int SHAKE = 1;
    /**
     * As a bubble display stack view.
     */
    public static final int BUBBLE = 2;

    private boolean mRelease = true;
    private int mMode;
    private static FragmentLifeCycle mLifeCycle = null;
    private static class LazyHolder {
        private static final DebugStackManager INSTANCE = new DebugStackManager();
    }

    private DebugStackManager(){}

    public static DebugStackManager getInstance(){
        return DebugStackManager.LazyHolder.INSTANCE;
    }

    public DebugStackManager setReleaseState(boolean flag){
        mRelease = flag;
        return this;
    }

    public DebugStackManager setMode(int mode){
        mMode = mode;
        return this;
    }

    public boolean needShowView(){
        if(mRelease){
            return false;
        }
        switch (mMode){
            case NONE:
                return false;
            case SHAKE:
            case BUBBLE:
                return  true;
            default:
                return false;
        }
    }

    public void setFragmentLifeListener(FragmentLifeCycle lifeListener){
        mLifeCycle = lifeListener;
    }

    public FragmentLifeCycle getFragmentLifeListener(){
        return mLifeCycle;
    }
}
