// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/AppComponent.java
// @ApplicationScope
// @Component(modules = AppModule.class)
// public interface AppComponent {
//     void inject(FlowTestApplication flowTestApplication);
// 
//     PostExecutionThread postExecutionThread();
//     UIThread uiThread();
//     ThreadExecutor threadExecutor();
//     ContactsRepository contactsRepository();
// 
//     SharedPreferences sharedPreferences();
// }
// 
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/AppModule.java
// @Module
// public class AppModule {
// 
//     private final static String SHARED_NAME = "global_config";
//     private final Application application;
// 
//     public AppModule(Application application) {
//         this.application = application;
//     }
// 
//     @Provides
//     @ApplicationScope
//     public Application providesApplication() {
//         return application;
//     }
// 
//     @Provides
//     @ApplicationScope
//     public UIThread provideUIThread() {
//         return new UIThread();
//     }
// 
//     @Provides
//     @ApplicationScope
//     public ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) {
//         return jobExecutor;
//     }
// 
//     @Provides
//     @ApplicationScope
//     public PostExecutionThread providePostExecutionThread(UIThread uiThread) {
//         return uiThread;
//     }
// 
//     @Provides
//     @ApplicationScope
//     public ContentResolver providesContentResolver() {
//         return this.application.getContentResolver();
//     }
// 
//     @Provides
//     @ApplicationScope
//     public ContactsRepository providesContactsRepository(ContentResolver contentResolver) {
//         return new ContactsRepositoryImpl(contentResolver);
//     }
// 
//     @Provides
//     @ApplicationScope
//     public SharedPreferences providesSharedPreferences() {
//         return this.application.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE);
//     }
// }


import android.app.Application;
import com.squareup.leakcanary.LeakCanary;
import leonardo2204.com.br.flowtests.di.DaggerService;
import leonardo2204.com.br.flowtests.di.component.AppComponent;
import leonardo2204.com.br.flowtests.di.component.DaggerAppComponent;
import leonardo2204.com.br.flowtests.di.module.AppModule;
import mortar.MortarScope;
package leonardo2204.com.br.flowtests;




/**
 * Created by Leonardo on 05/03/2016.
 */
public class FlowTestApplication extends Application {

    private MortarScope mortarScope;

    @Override
    public Object getSystemService(String name) {
        if(mortarScope == null){
            setupMortar();
        }

        return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        LeakCanary.install(this);
    }

    private void setupMortar(){
        AppComponent component = DaggerAppComponent
                .builder()
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/AppComponent.java
// @ApplicationScope
// @Component(modules = AppModule.class)
// public interface AppComponent {
//     void inject(FlowTestApplication flowTestApplication);
// 
//     PostExecutionThread postExecutionThread();
//     UIThread uiThread();
//     ThreadExecutor threadExecutor();
//     ContactsRepository contactsRepository();
// 
//     SharedPreferences sharedPreferences();
// }
// 
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/AppModule.java
// @Module
// public class AppModule {
// 
//     private final static String SHARED_NAME = "global_config";
//     private final Application application;
// 
//     public AppModule(Application application) {
//         this.application = application;
//     }
// 
//     @Provides
//     @ApplicationScope
//     public Application providesApplication() {
//         return application;
//     }
// 
//     @Provides
//     @ApplicationScope
//     public UIThread provideUIThread() {
//         return new UIThread();
//     }
// 
//     @Provides
//     @ApplicationScope
//     public ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) {
//         return jobExecutor;
//     }
// 
//     @Provides
//     @ApplicationScope
//     public PostExecutionThread providePostExecutionThread(UIThread uiThread) {
//         return uiThread;
//     }
// 
//     @Provides
//     @ApplicationScope
//     public ContentResolver providesContentResolver() {
//         return this.application.getContentResolver();
//     }
// 
//     @Provides
//     @ApplicationScope
//     public ContactsRepository providesContactsRepository(ContentResolver contentResolver) {
//         return new ContactsRepositoryImpl(contentResolver);
//     }
// 
//     @Provides
//     @ApplicationScope
//     public SharedPreferences providesSharedPreferences() {
//         return this.application.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE);
//     }
// }


// Path: app/src/main/java/leonardo2204/com/br/flowtests/FlowTestApplication.java
import android.app.Application;
import com.squareup.leakcanary.LeakCanary;
import leonardo2204.com.br.flowtests.di.DaggerService;
import leonardo2204.com.br.flowtests.di.component.AppComponent;
import leonardo2204.com.br.flowtests.di.component.DaggerAppComponent;
import leonardo2204.com.br.flowtests.di.module.AppModule;
import mortar.MortarScope;

package leonardo2204.com.br.flowtests;




/**
 * Created by Leonardo on 05/03/2016.
 */
public class FlowTestApplication extends Application {

    private MortarScope mortarScope;

    @Override
    public Object getSystemService(String name) {
        if(mortarScope == null){
            setupMortar();
        }

        return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        LeakCanary.install(this);
    }

    private void setupMortar(){
        AppComponent component = DaggerAppComponent
                .builder()
                .appModule(new AppModule(this))