// Path: app/src/main/java/com/starter/data/preferences/ApplicationPreferences.java
// public class ApplicationPreferences {
//     private static final String KEY_SENT_GCM_TOKEN_TO_SERVER = "KEY_SENT_GCM_TOKEN_TO_SERVER";
// 
//     SharedPreferences sharedPreferences = null;
// 
//     public ApplicationPreferences(SharedPreferences sharedPreferences) {
//         this.sharedPreferences = sharedPreferences;
//     }
// }
// 
// Path: app/src/main/java/com/starter/utils/ThreadConfiguration.java
// public class ThreadConfiguration {
//     private Scheduler subscribeOnScheduler;
//     private Scheduler observeOnScheduler;
// 
//     public ThreadConfiguration(final Scheduler subscribeOnScheduler,
//         final Scheduler observeOnScheduler) {
//         this.subscribeOnScheduler = subscribeOnScheduler;
//         this.observeOnScheduler = observeOnScheduler;
//     }
// 
//     public <T> Observable.Transformer<T, T> applySchedulers() {
//         return observable -> observable.subscribeOn(subscribeOnScheduler)
//             .observeOn(observeOnScheduler);
//     }
// }


import android.app.Application;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.jakewharton.picasso.OkHttp3Downloader;
import com.squareup.picasso.Picasso;
import com.starter.data.preferences.ApplicationPreferences;
import com.starter.utils.ThreadConfiguration;
import dagger.Module;
import dagger.Provides;
import java.io.File;
import javax.inject.Singleton;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
package com.starter.di;


@Module
public class AppModule {
    private static final String IMAGE_CACHE_DIR = "cache_images";
    private static final int IMAGE_DISK_CACHE_SIZE = 100 * 1024 * 1024; // 100MB
    private final Application application;

    public AppModule(Application application) {
        this.application = application;
    }

    @Provides
    @Singleton
    Application provideApplication() {
        return application;
    }

    @Provides
    @Singleton
    Picasso providePicasso(final Application app) {
        final OkHttpClient.Builder httpBuilder = new OkHttpClient.Builder();

        File cacheDir = new File(app.getCacheDir(), IMAGE_CACHE_DIR);
        httpBuilder.cache(new Cache(cacheDir, IMAGE_DISK_CACHE_SIZE));
        final OkHttp3Downloader okHttpDownloader = new OkHttp3Downloader(httpBuilder.build());

// Path: app/src/main/java/com/starter/data/preferences/ApplicationPreferences.java
// public class ApplicationPreferences {
//     private static final String KEY_SENT_GCM_TOKEN_TO_SERVER = "KEY_SENT_GCM_TOKEN_TO_SERVER";
// 
//     SharedPreferences sharedPreferences = null;
// 
//     public ApplicationPreferences(SharedPreferences sharedPreferences) {
//         this.sharedPreferences = sharedPreferences;
//     }
// }
// 
// Path: app/src/main/java/com/starter/utils/ThreadConfiguration.java
// public class ThreadConfiguration {
//     private Scheduler subscribeOnScheduler;
//     private Scheduler observeOnScheduler;
// 
//     public ThreadConfiguration(final Scheduler subscribeOnScheduler,
//         final Scheduler observeOnScheduler) {
//         this.subscribeOnScheduler = subscribeOnScheduler;
//         this.observeOnScheduler = observeOnScheduler;
//     }
// 
//     public <T> Observable.Transformer<T, T> applySchedulers() {
//         return observable -> observable.subscribeOn(subscribeOnScheduler)
//             .observeOn(observeOnScheduler);
//     }
// }


// Path: app/src/main/java/com/starter/di/AppModule.java
import android.app.Application;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.jakewharton.picasso.OkHttp3Downloader;
import com.squareup.picasso.Picasso;
import com.starter.data.preferences.ApplicationPreferences;
import com.starter.utils.ThreadConfiguration;
import dagger.Module;
import dagger.Provides;
import java.io.File;
import javax.inject.Singleton;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

package com.starter.di;


@Module
public class AppModule {
    private static final String IMAGE_CACHE_DIR = "cache_images";
    private static final int IMAGE_DISK_CACHE_SIZE = 100 * 1024 * 1024; // 100MB
    private final Application application;

    public AppModule(Application application) {
        this.application = application;
    }

    @Provides
    @Singleton
    Application provideApplication() {
        return application;
    }

    @Provides
    @Singleton
    Picasso providePicasso(final Application app) {
        final OkHttpClient.Builder httpBuilder = new OkHttpClient.Builder();

        File cacheDir = new File(app.getCacheDir(), IMAGE_CACHE_DIR);
        httpBuilder.cache(new Cache(cacheDir, IMAGE_DISK_CACHE_SIZE));
        final OkHttp3Downloader okHttpDownloader = new OkHttp3Downloader(httpBuilder.build());

        return new Picasso.Builder(app).downloader(okHttpDownloader).indicatorsEnabled(true).build();