// Path: app/src/main/java/io/github/krtkush/marsexplorer/RESTClients/MarsWeatherClient.java
// public class MarsWeatherClient {
// 
//     private static MarsWeatherInterface marsWeatherInterface;
// 
//     public static MarsWeatherInterface getMarsWeatherInterface() {
// 
//         if(marsWeatherInterface == null) {
// 
//             // Log level depending on build type. No logging in case of production APK
//             HttpLoggingInterceptor.Level logLevel;
// 
//             if(BuildConfig.DEBUG)
//                 logLevel = HttpLoggingInterceptor.Level.BODY;
//             else
//                 logLevel = HttpLoggingInterceptor.Level.NONE;
// 
//             OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                     // Enable response caching
//                     .addNetworkInterceptor(new ResponseCacheInterceptor())
//                     // Set the cache location and size (5 MB)
//                     .cache(new Cache(new File(MarsExplorerApplication.getApplicationInstance()
//                             .getCacheDir(), RestClientConstants.apiResponsesCache),
//                             5 * 1024 * 1024))
//                     // Enable logging
//                     .addInterceptor(new HttpLoggingInterceptor()
//                             .setLevel(logLevel))
//                     .build();
// 
//             GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(
//                     new GsonBuilder()
//                             .registerTypeAdapterFactory(GsonTypeAdapterAdapterFactory.create())
//                             .create()
//             );
// 
//             Retrofit retrofitClient = new Retrofit.Builder()
//                     .baseUrl(RestClientConstants.marsWeatherBaseUrl)
//                     .client(okHttpClient)
//                     .addConverterFactory(gsonConverterFactory)
//                     .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
//                     .build();
// 
//             marsWeatherInterface = retrofitClient.create(MarsWeatherInterface.class);
//         }
// 
//         return marsWeatherInterface;
//     }
// 
//     public interface MarsWeatherInterface {
// 
//         @GET("api.php")
//         Observable<MarsWeatherResultDM> getLatestMarsWeather(
//                 @Header(RestClientConstants.responseCachingFlagHeader) boolean responseCacheFlag
//         );
//     }
// }
// 
// Path: app/src/main/java/io/github/krtkush/marsexplorer/RESTClients/NASARestApiClient.java
// public class NASARestApiClient {
// 
//     private static NASAMarsPhotosApiInterface nasaMarsPhotosApiInterface;
// 
//     public static NASAMarsPhotosApiInterface getNasaMarsPhotosApiInterface() {
// 
//         if(nasaMarsPhotosApiInterface == null) {
// 
//             // Log level depending on build type. No logging in case of production APK
//             HttpLoggingInterceptor.Level logLevel;
// 
//             if(BuildConfig.DEBUG)
//                 logLevel = HttpLoggingInterceptor.Level.BODY;
//             else
//                 logLevel = HttpLoggingInterceptor.Level.NONE;
// 
//             OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                     // Enable response caching
//                     .addNetworkInterceptor(new ResponseCacheInterceptor())
//                     .addInterceptor(new OfflineResponseCacheInterceptor())
//                     // Set the cache location and size (5 MB)
//                     .cache(new Cache(new File(MarsExplorerApplication.getApplicationInstance()
//                             .getCacheDir(), RestClientConstants.apiResponsesCache),
//                             5 * 1024 * 1024))
//                     // Add the api key by default
//                     .addInterceptor(new DefaultValuesInterceptor
//                             (MarsExplorerApplication.getApplicationInstance()
//                                     .getString(R.string.NASA_API_KEY)))
//                     // Enable logging
//                     .addInterceptor(new HttpLoggingInterceptor()
//                             .setLevel(logLevel))
//                     // Set the timeout periods
//                     .readTimeout(60, TimeUnit.SECONDS)
//                     .connectTimeout(60, TimeUnit.SECONDS)
//                     .build();
// 
//             GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(
//                     new GsonBuilder()
//                             .registerTypeAdapterFactory(GsonTypeAdapterAdapterFactory.create())
//                             .create()
//             );
// 
//             Retrofit retrofitClient = new Retrofit.Builder()
//                     .baseUrl(RestClientConstants.nasaApiBaseUrl)
//                     .client(okHttpClient)
//                     .addConverterFactory(gsonConverterFactory)
//                     .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
//                     .build();
// 
//             nasaMarsPhotosApiInterface = retrofitClient.create(NASAMarsPhotosApiInterface.class);
//         }
// 
//         return nasaMarsPhotosApiInterface;
//     }
// 
//     public interface NASAMarsPhotosApiInterface {
// 
//         @GET("{roverName}/photos")
//         Observable<PhotosResultDM> getPhotosBySol(
//                 @Header(RestClientConstants.offlineCachingFlagHeader) boolean offlineCacheFlag,
//                 @Header(RestClientConstants.responseCachingFlagHeader) boolean responseCacheFlag,
//                 @Path("roverName") String roverName,
//                 @Query("sol") String SOL);
//     }
// 
//     /**
//      * Interceptor that, by default, adds required query parameter(s) in every API request.
//      */
//     private static class DefaultValuesInterceptor implements Interceptor {
// 
//         private String apiKey;
// 
//         public DefaultValuesInterceptor(String apiKey) {
//             this.apiKey = apiKey;
//         }
// 
//         @Override
//         public Response intercept(Chain chain) throws IOException {
//             Request request = chain.request();
//             HttpUrl url = request.url().newBuilder()
//                     .addQueryParameter("api_key", this.apiKey)
//                     .build();
//             request = request.newBuilder().url(url).build();
//             return chain.proceed(request);
//         }
//     }
// }


import android.app.Application;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.picasso.Picasso;
import io.github.krtkush.marsexplorer.RESTClients.MarsWeatherClient;
import io.github.krtkush.marsexplorer.RESTClients.NASARestApiClient;
import timber.log.Timber;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
package io.github.krtkush.marsexplorer;




/**
 * Created by kartikeykushwaha on 21/05/16.
 */
public class MarsExplorerApplication extends Application {

    // Variable that holds instance of the application class
    private static MarsExplorerApplication marsExplorerApplicationInstance;
    // Variable that holds instance of the photos API interface
// Path: app/src/main/java/io/github/krtkush/marsexplorer/RESTClients/MarsWeatherClient.java
// public class MarsWeatherClient {
// 
//     private static MarsWeatherInterface marsWeatherInterface;
// 
//     public static MarsWeatherInterface getMarsWeatherInterface() {
// 
//         if(marsWeatherInterface == null) {
// 
//             // Log level depending on build type. No logging in case of production APK
//             HttpLoggingInterceptor.Level logLevel;
// 
//             if(BuildConfig.DEBUG)
//                 logLevel = HttpLoggingInterceptor.Level.BODY;
//             else
//                 logLevel = HttpLoggingInterceptor.Level.NONE;
// 
//             OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                     // Enable response caching
//                     .addNetworkInterceptor(new ResponseCacheInterceptor())
//                     // Set the cache location and size (5 MB)
//                     .cache(new Cache(new File(MarsExplorerApplication.getApplicationInstance()
//                             .getCacheDir(), RestClientConstants.apiResponsesCache),
//                             5 * 1024 * 1024))
//                     // Enable logging
//                     .addInterceptor(new HttpLoggingInterceptor()
//                             .setLevel(logLevel))
//                     .build();
// 
//             GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(
//                     new GsonBuilder()
//                             .registerTypeAdapterFactory(GsonTypeAdapterAdapterFactory.create())
//                             .create()
//             );
// 
//             Retrofit retrofitClient = new Retrofit.Builder()
//                     .baseUrl(RestClientConstants.marsWeatherBaseUrl)
//                     .client(okHttpClient)
//                     .addConverterFactory(gsonConverterFactory)
//                     .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
//                     .build();
// 
//             marsWeatherInterface = retrofitClient.create(MarsWeatherInterface.class);
//         }
// 
//         return marsWeatherInterface;
//     }
// 
//     public interface MarsWeatherInterface {
// 
//         @GET("api.php")
//         Observable<MarsWeatherResultDM> getLatestMarsWeather(
//                 @Header(RestClientConstants.responseCachingFlagHeader) boolean responseCacheFlag
//         );
//     }
// }
// 
// Path: app/src/main/java/io/github/krtkush/marsexplorer/RESTClients/NASARestApiClient.java
// public class NASARestApiClient {
// 
//     private static NASAMarsPhotosApiInterface nasaMarsPhotosApiInterface;
// 
//     public static NASAMarsPhotosApiInterface getNasaMarsPhotosApiInterface() {
// 
//         if(nasaMarsPhotosApiInterface == null) {
// 
//             // Log level depending on build type. No logging in case of production APK
//             HttpLoggingInterceptor.Level logLevel;
// 
//             if(BuildConfig.DEBUG)
//                 logLevel = HttpLoggingInterceptor.Level.BODY;
//             else
//                 logLevel = HttpLoggingInterceptor.Level.NONE;
// 
//             OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                     // Enable response caching
//                     .addNetworkInterceptor(new ResponseCacheInterceptor())
//                     .addInterceptor(new OfflineResponseCacheInterceptor())
//                     // Set the cache location and size (5 MB)
//                     .cache(new Cache(new File(MarsExplorerApplication.getApplicationInstance()
//                             .getCacheDir(), RestClientConstants.apiResponsesCache),
//                             5 * 1024 * 1024))
//                     // Add the api key by default
//                     .addInterceptor(new DefaultValuesInterceptor
//                             (MarsExplorerApplication.getApplicationInstance()
//                                     .getString(R.string.NASA_API_KEY)))
//                     // Enable logging
//                     .addInterceptor(new HttpLoggingInterceptor()
//                             .setLevel(logLevel))
//                     // Set the timeout periods
//                     .readTimeout(60, TimeUnit.SECONDS)
//                     .connectTimeout(60, TimeUnit.SECONDS)
//                     .build();
// 
//             GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(
//                     new GsonBuilder()
//                             .registerTypeAdapterFactory(GsonTypeAdapterAdapterFactory.create())
//                             .create()
//             );
// 
//             Retrofit retrofitClient = new Retrofit.Builder()
//                     .baseUrl(RestClientConstants.nasaApiBaseUrl)
//                     .client(okHttpClient)
//                     .addConverterFactory(gsonConverterFactory)
//                     .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
//                     .build();
// 
//             nasaMarsPhotosApiInterface = retrofitClient.create(NASAMarsPhotosApiInterface.class);
//         }
// 
//         return nasaMarsPhotosApiInterface;
//     }
// 
//     public interface NASAMarsPhotosApiInterface {
// 
//         @GET("{roverName}/photos")
//         Observable<PhotosResultDM> getPhotosBySol(
//                 @Header(RestClientConstants.offlineCachingFlagHeader) boolean offlineCacheFlag,
//                 @Header(RestClientConstants.responseCachingFlagHeader) boolean responseCacheFlag,
//                 @Path("roverName") String roverName,
//                 @Query("sol") String SOL);
//     }
// 
//     /**
//      * Interceptor that, by default, adds required query parameter(s) in every API request.
//      */
//     private static class DefaultValuesInterceptor implements Interceptor {
// 
//         private String apiKey;
// 
//         public DefaultValuesInterceptor(String apiKey) {
//             this.apiKey = apiKey;
//         }
// 
//         @Override
//         public Response intercept(Chain chain) throws IOException {
//             Request request = chain.request();
//             HttpUrl url = request.url().newBuilder()
//                     .addQueryParameter("api_key", this.apiKey)
//                     .build();
//             request = request.newBuilder().url(url).build();
//             return chain.proceed(request);
//         }
//     }
// }


// Path: app/src/main/java/io/github/krtkush/marsexplorer/MarsExplorerApplication.java
import android.app.Application;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.picasso.Picasso;
import io.github.krtkush.marsexplorer.RESTClients.MarsWeatherClient;
import io.github.krtkush.marsexplorer.RESTClients.NASARestApiClient;
import timber.log.Timber;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;

package io.github.krtkush.marsexplorer;




/**
 * Created by kartikeykushwaha on 21/05/16.
 */
public class MarsExplorerApplication extends Application {

    // Variable that holds instance of the application class
    private static MarsExplorerApplication marsExplorerApplicationInstance;
    // Variable that holds instance of the photos API interface
    private NASARestApiClient.NASAMarsPhotosApiInterface nasaMarsPhotosApiInterface;