// Path: library/src/main/java/flownavigation/path/Path.java
// public abstract class Path {
// 
//     static final Path ROOT = new Path() {
//     };
// 
//     public static PathContextFactory contextFactory() {
//         return new ContextFactory();
//     }
// 
//     public static PathContextFactory contextFactory(PathContextFactory delegate) {
//         return new ContextFactory(delegate);
//     }
// 
//     private static final class LocalPathWrapper extends ContextWrapper {
//         static final String LOCAL_WRAPPER_SERVICE = "flow_local_screen_context_wrapper";
//         private LayoutInflater inflater;
// 
//         final Object localScreen;
// 
//         LocalPathWrapper(Context base, Object localScreen) {
//             super(base);
//             this.localScreen = localScreen;
//         }
// 
//         @Override
//         public Object getSystemService(String name) {
//             if (LOCAL_WRAPPER_SERVICE.equals(name)) {
//                 return this;
//             }
//             if (LAYOUT_INFLATER_SERVICE.equals(name)) {
//                 if (inflater == null) {
//                     inflater = LayoutInflater.from(getBaseContext()).cloneInContext(this);
//                 }
//                 return inflater;
//             }
//             return super.getSystemService(name);
//         }
//     }
// 
//     private static final class ContextFactory implements PathContextFactory {
//         // May be null.
//         private final PathContextFactory delegate;
// 
//         public ContextFactory() {
//             delegate = null;
//         }
// 
//         public ContextFactory(PathContextFactory delegate) {
//             this.delegate = delegate;
//         }
// 
//         @Override
//         public Context setUpContext(Path path, Context parentContext) {
//             if (delegate != null) {
//                 parentContext = delegate.setUpContext(path, parentContext);
//             }
//             return new LocalPathWrapper(parentContext, path);
//         }
// 
//         @Override
//         public void tearDownContext(Context context) {
//             if (delegate != null) {
//                 delegate.tearDownContext(context);
//             }
//         }
//     }
// }
// 
// Path: library/src/main/java/flownavigation/path/PathContextFactory.java
// public interface PathContextFactory {
//     /**
//      * Set up any services defined by this screen, and make them accessible via the context.
//      * Typically this means returning a new context that wraps the given one.
//      */
//     Context setUpContext(Path path, Context parentContext);
// 
//     /**
//      * Tear down any services previously started by {@link #setUpContext(Path, Context)}. Note that
//      * the Context instance given here may be a wrapper around an instance that this factory
//      * created.
//      */
//     void tearDownContext(Context context);
// }


import android.content.Context;
import android.content.ContextWrapper;
import android.util.Log;
import android.view.LayoutInflater;
import flownavigation.path.Path;
import flownavigation.path.PathContextFactory;
import mortar.MortarScope;
package flownavigation.common.mortar;



/**
 * @author Lukasz Piliszczuk - lukasz.pili@gmail.com
 */
public class BasicMortarContextFactory implements PathContextFactory {

    private final ScreenScoper screenScoper;

    public BasicMortarContextFactory(ScreenScoper screenScoper) {
        this.screenScoper = screenScoper;
    }

    @Override
// Path: library/src/main/java/flownavigation/path/Path.java
// public abstract class Path {
// 
//     static final Path ROOT = new Path() {
//     };
// 
//     public static PathContextFactory contextFactory() {
//         return new ContextFactory();
//     }
// 
//     public static PathContextFactory contextFactory(PathContextFactory delegate) {
//         return new ContextFactory(delegate);
//     }
// 
//     private static final class LocalPathWrapper extends ContextWrapper {
//         static final String LOCAL_WRAPPER_SERVICE = "flow_local_screen_context_wrapper";
//         private LayoutInflater inflater;
// 
//         final Object localScreen;
// 
//         LocalPathWrapper(Context base, Object localScreen) {
//             super(base);
//             this.localScreen = localScreen;
//         }
// 
//         @Override
//         public Object getSystemService(String name) {
//             if (LOCAL_WRAPPER_SERVICE.equals(name)) {
//                 return this;
//             }
//             if (LAYOUT_INFLATER_SERVICE.equals(name)) {
//                 if (inflater == null) {
//                     inflater = LayoutInflater.from(getBaseContext()).cloneInContext(this);
//                 }
//                 return inflater;
//             }
//             return super.getSystemService(name);
//         }
//     }
// 
//     private static final class ContextFactory implements PathContextFactory {
//         // May be null.
//         private final PathContextFactory delegate;
// 
//         public ContextFactory() {
//             delegate = null;
//         }
// 
//         public ContextFactory(PathContextFactory delegate) {
//             this.delegate = delegate;
//         }
// 
//         @Override
//         public Context setUpContext(Path path, Context parentContext) {
//             if (delegate != null) {
//                 parentContext = delegate.setUpContext(path, parentContext);
//             }
//             return new LocalPathWrapper(parentContext, path);
//         }
// 
//         @Override
//         public void tearDownContext(Context context) {
//             if (delegate != null) {
//                 delegate.tearDownContext(context);
//             }
//         }
//     }
// }
// 
// Path: library/src/main/java/flownavigation/path/PathContextFactory.java
// public interface PathContextFactory {
//     /**
//      * Set up any services defined by this screen, and make them accessible via the context.
//      * Typically this means returning a new context that wraps the given one.
//      */
//     Context setUpContext(Path path, Context parentContext);
// 
//     /**
//      * Tear down any services previously started by {@link #setUpContext(Path, Context)}. Note that
//      * the Context instance given here may be a wrapper around an instance that this factory
//      * created.
//      */
//     void tearDownContext(Context context);
// }


// Path: mortar-common/src/main/java/flownavigation/common/mortar/BasicMortarContextFactory.java
import android.content.Context;
import android.content.ContextWrapper;
import android.util.Log;
import android.view.LayoutInflater;
import flownavigation.path.Path;
import flownavigation.path.PathContextFactory;
import mortar.MortarScope;

package flownavigation.common.mortar;



/**
 * @author Lukasz Piliszczuk - lukasz.pili@gmail.com
 */
public class BasicMortarContextFactory implements PathContextFactory {

    private final ScreenScoper screenScoper;

    public BasicMortarContextFactory(ScreenScoper screenScoper) {
        this.screenScoper = screenScoper;
    }

    @Override
    public Context setUpContext(Path path, Context parentContext) {