// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java
// public interface PrivvyHost {
// 
//     void initialize(RouteData... routes);
// 
//     void replace(RouteData oldComponent, RouteData newComponent);
// 
//     void goTo(RouteData newComponent);
// }
// 
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java
// public class PrivvyHostDelegate implements PrivvyHost {
// 
//     private AppCompatActivity hostActivity;
// 
//     public PrivvyHostDelegate(AppCompatActivity hostActivity) {
//         this.hostActivity = hostActivity;
//     }
// 
//     @Override
//     public void initialize(RouteData... routeData) {
//         for (RouteData data : routeData) {
//             startComponent(data);
//         }
//     }
// 
//     private void startComponent(RouteData routeData) {
//         switch (routeData.viewType()) {
//             case ACTIVITY:
//                 goTo(routeData);
//                 break;
//             case FRAGMENT:
//                 startFragment(routeData);
//                 break;
//         }
//     }
// 
//     @Override
//     public void goTo(RouteData newComponent) {
//         hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass()));
//     }
// 
//     private void startFragment(RouteData routeData) {
//         commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag());
//     }
// 
//     @Override
//     public void replace(RouteData oldComponent, RouteData newComponent) {
//         commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag());
//     }
// 
//     @SuppressWarnings("TryWithIdenticalCatches")
//     private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) {
//         try {
//             FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction();
//             ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag);
//             ft.commit();
//         } catch (InstantiationException e) {
//             e.printStackTrace();
//         } catch (IllegalAccessException e) {
//             e.printStackTrace();
//         }
//     }
// }
// 
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java
// @AutoValue
// public abstract class RouteData {
// 
//     public abstract ViewType viewType();
//     public abstract Class<?> viewClass();
//     public abstract int viewId();
// 
//     public static Builder Builder() {
//         return new AutoValue_RouteData.Builder().viewId(0);
//     }
// 
//     public String tag() {
//         return viewClass().getSimpleName();
//     }
// 
//     @AutoValue.Builder
//     public interface Builder {
//         Builder viewType(ViewType viewType);
//         Builder viewClass(Class<?> viewClass);
//         Builder viewId(@IdRes int viewId);
//         RouteData build();
//     }
// }
// 
// Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java
// @HostScope
// @Subcomponent(modules = {HostModule.class, YokeModule.class})
// public interface HostComponent {
// 
//     PrivvyComponent newPrivvyComponent();
// 
//     @Subcomponent.Builder
//     interface Builder {
// 
//         HostComponent.Builder hostModule(HostModule module);
// 
//         HostComponent build();
//     }
// }
// 
// Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java
// @Module
// public class HostModule {
// 
//     private final PrivvyHost host;
// 
//     public HostModule(PrivvyHost host) {
//         this.host = host;
//     }
// 
//     @Provides
//     @HostScope
//     PrivvyHost provideHost() {
//         return host;
//     }
// }
// 
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java
// @ButtonScope
// @Subcomponent(modules = {ButtonModule.class})
// public interface ButtonComponent {
// 
//     RouteData ROUTE_DATA = RouteData.Builder()
//             .viewType(ViewType.FRAGMENT)
//             .viewClass(ButtonFragment.class)
//             .viewId(R.id.button_component)
//             .build();
// 
//     ButtonContract.Presenter presenter();
// 
//     @Subcomponent.Builder
//     interface Builder {
// 
//         Builder buttonModule(ButtonModule module);
// 
//         ButtonComponent build();
//     }
// }
// 
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java
// @NumberScope
// @Subcomponent(modules = {NumberModule.class})
// public interface NumberComponent {
// 
//     RouteData ROUTE_DATA = RouteData.Builder()
//             .viewType(ViewType.FRAGMENT)
//             .viewClass(NumberFragment.class)
//             .viewId(R.id.number_component)
//             .build();
// 
//     NumberContract.Presenter presenter();
// 
//     @Subcomponent.Builder
//     interface Builder {
//         Builder numberModule(NumberModule module);
// 
//         NumberComponent build();
//     }
// }


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.metova.privvy.PrivvyHost;
import com.metova.privvy.PrivvyHostDelegate;
import com.metova.privvy.RouteData;
import com.metova.privvy.sample.di.HostComponent;
import com.metova.privvy.sample.di.HostModule;
import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent;
import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent;
package com.metova.privvy.sample;


public class MainActivity extends AppCompatActivity implements PrivvyHost {

    public HostComponent hostComponent;

    private PrivvyHostDelegate hostDelegate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        hostComponent = SampleApplication.component.newHost()
                .hostModule(new HostModule(this))
                .build();

        hostDelegate = new PrivvyHostDelegate(this);

        setContentView(R.layout.main_activity);

        initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA);
    }

    @Override
    public void initialize(RouteData... routeData) {
        hostDelegate.initialize(routeData);
    }

    @Override
    public void replace(RouteData oldComponent, RouteData newComponent) {
        hostDelegate.replace(oldComponent, newComponent);
    }

    @Override
    public void goTo(RouteData newComponent) {
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHost.java
// public interface PrivvyHost {
// 
//     void initialize(RouteData... routes);
// 
//     void replace(RouteData oldComponent, RouteData newComponent);
// 
//     void goTo(RouteData newComponent);
// }
// 
// Path: privvy/src/main/java/com/metova/privvy/PrivvyHostDelegate.java
// public class PrivvyHostDelegate implements PrivvyHost {
// 
//     private AppCompatActivity hostActivity;
// 
//     public PrivvyHostDelegate(AppCompatActivity hostActivity) {
//         this.hostActivity = hostActivity;
//     }
// 
//     @Override
//     public void initialize(RouteData... routeData) {
//         for (RouteData data : routeData) {
//             startComponent(data);
//         }
//     }
// 
//     private void startComponent(RouteData routeData) {
//         switch (routeData.viewType()) {
//             case ACTIVITY:
//                 goTo(routeData);
//                 break;
//             case FRAGMENT:
//                 startFragment(routeData);
//                 break;
//         }
//     }
// 
//     @Override
//     public void goTo(RouteData newComponent) {
//         hostActivity.startActivity(new Intent(hostActivity, newComponent.viewClass()));
//     }
// 
//     private void startFragment(RouteData routeData) {
//         commitFragmentTransaction(routeData.viewId(), routeData.viewClass(), routeData.tag());
//     }
// 
//     @Override
//     public void replace(RouteData oldComponent, RouteData newComponent) {
//         commitFragmentTransaction(oldComponent.viewId(), newComponent.viewClass(), newComponent.tag());
//     }
// 
//     @SuppressWarnings("TryWithIdenticalCatches")
//     private void commitFragmentTransaction(@IdRes int viewId, Class<?> fragmentClass, String tag) {
//         try {
//             FragmentTransaction ft = hostActivity.getSupportFragmentManager().beginTransaction();
//             ft.replace(viewId, (Fragment) fragmentClass.newInstance(), tag);
//             ft.commit();
//         } catch (InstantiationException e) {
//             e.printStackTrace();
//         } catch (IllegalAccessException e) {
//             e.printStackTrace();
//         }
//     }
// }
// 
// Path: privvy/src/main/java/com/metova/privvy/RouteData.java
// @AutoValue
// public abstract class RouteData {
// 
//     public abstract ViewType viewType();
//     public abstract Class<?> viewClass();
//     public abstract int viewId();
// 
//     public static Builder Builder() {
//         return new AutoValue_RouteData.Builder().viewId(0);
//     }
// 
//     public String tag() {
//         return viewClass().getSimpleName();
//     }
// 
//     @AutoValue.Builder
//     public interface Builder {
//         Builder viewType(ViewType viewType);
//         Builder viewClass(Class<?> viewClass);
//         Builder viewId(@IdRes int viewId);
//         RouteData build();
//     }
// }
// 
// Path: sample/src/main/java/com/metova/privvy/sample/di/HostComponent.java
// @HostScope
// @Subcomponent(modules = {HostModule.class, YokeModule.class})
// public interface HostComponent {
// 
//     PrivvyComponent newPrivvyComponent();
// 
//     @Subcomponent.Builder
//     interface Builder {
// 
//         HostComponent.Builder hostModule(HostModule module);
// 
//         HostComponent build();
//     }
// }
// 
// Path: sample/src/main/java/com/metova/privvy/sample/di/HostModule.java
// @Module
// public class HostModule {
// 
//     private final PrivvyHost host;
// 
//     public HostModule(PrivvyHost host) {
//         this.host = host;
//     }
// 
//     @Provides
//     @HostScope
//     PrivvyHost provideHost() {
//         return host;
//     }
// }
// 
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/buttons/ButtonComponent.java
// @ButtonScope
// @Subcomponent(modules = {ButtonModule.class})
// public interface ButtonComponent {
// 
//     RouteData ROUTE_DATA = RouteData.Builder()
//             .viewType(ViewType.FRAGMENT)
//             .viewClass(ButtonFragment.class)
//             .viewId(R.id.button_component)
//             .build();
// 
//     ButtonContract.Presenter presenter();
// 
//     @Subcomponent.Builder
//     interface Builder {
// 
//         Builder buttonModule(ButtonModule module);
// 
//         ButtonComponent build();
//     }
// }
// 
// Path: sample/src/main/java/com/metova/privvy/sample/ui/floatingnumber/number/NumberComponent.java
// @NumberScope
// @Subcomponent(modules = {NumberModule.class})
// public interface NumberComponent {
// 
//     RouteData ROUTE_DATA = RouteData.Builder()
//             .viewType(ViewType.FRAGMENT)
//             .viewClass(NumberFragment.class)
//             .viewId(R.id.number_component)
//             .build();
// 
//     NumberContract.Presenter presenter();
// 
//     @Subcomponent.Builder
//     interface Builder {
//         Builder numberModule(NumberModule module);
// 
//         NumberComponent build();
//     }
// }


// Path: sample/src/main/java/com/metova/privvy/sample/MainActivity.java
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.metova.privvy.PrivvyHost;
import com.metova.privvy.PrivvyHostDelegate;
import com.metova.privvy.RouteData;
import com.metova.privvy.sample.di.HostComponent;
import com.metova.privvy.sample.di.HostModule;
import com.metova.privvy.sample.ui.floatingnumber.buttons.ButtonComponent;
import com.metova.privvy.sample.ui.floatingnumber.number.NumberComponent;

package com.metova.privvy.sample;


public class MainActivity extends AppCompatActivity implements PrivvyHost {

    public HostComponent hostComponent;

    private PrivvyHostDelegate hostDelegate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        hostComponent = SampleApplication.component.newHost()
                .hostModule(new HostModule(this))
                .build();

        hostDelegate = new PrivvyHostDelegate(this);

        setContentView(R.layout.main_activity);

        initialize(NumberComponent.ROUTE_DATA, ButtonComponent.ROUTE_DATA);
    }

    @Override
    public void initialize(RouteData... routeData) {
        hostDelegate.initialize(routeData);
    }

    @Override
    public void replace(RouteData oldComponent, RouteData newComponent) {
        hostDelegate.replace(oldComponent, newComponent);
    }

    @Override
    public void goTo(RouteData newComponent) {
        hostDelegate.goTo(newComponent);