// Path: app/src/main/java/me/yifeiyuan/climb/di/modules/ApiModule.java
// @Module
// public class ApiModule {
// 
//     @Singleton
//     @Provides
//     OkHttpClient provideOkHttpClient() {
//         OkHttpClient.Builder builder = new OkHttpClient.Builder()
//                 .connectTimeout(30_000, TimeUnit.MILLISECONDS)
//                 .readTimeout(30_000, TimeUnit.MILLISECONDS)
//                 .writeTimeout(30_000, TimeUnit.MILLISECONDS);
// 
//         if (BuildConfig.DEBUG) {
//             HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
//             logging.setLevel(HttpLoggingInterceptor.Level.BODY);
//             builder.addInterceptor(logging);
//         }
// 
//         return builder.build();
//     }
// 
//     @Singleton
//     @Provides
//     Gson provideGson() {
//         return new GsonBuilder()
//                 .setDateFormat("yyyy-MM-dd")   //("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
//                 .create();
//     }
// 
//     @Singleton
//     @Provides
//     Retrofit provideRetrofit(OkHttpClient client, Gson gson) {
//         Retrofit retrofit = new Retrofit.Builder()
//                 .baseUrl(GankConfig.URL_DOMAIN)
//                 .addConverterFactory(GsonConverterFactory.create(gson))
//                 .addCallAdapterFactory(RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io()))
//                 .client(client)
//                 .build();
// 
//         return retrofit;
//     }
// 
//     @Singleton
//     @Provides
//     GankApi provideGankApi(Retrofit retrofit) {
//         return retrofit.create(GankApi.class);
//     }
// 
//     @Singleton
//     @Provides
//     ZhiHuApi provideZhiHuApi(Retrofit retrofit) {
//         return retrofit.create(ZhiHuApi.class);
//     }
// 
//     @Singleton
//     @Provides
//     WeatherApi provideWeatherApi(Retrofit retrofit) {
//         return retrofit.create(WeatherApi.class);
//     }
// 
// }
// 
// Path: app/src/main/java/me/yifeiyuan/climb/network/api/Api.java
// public class Api {
// 
//     private final GankApi mGankApi;
//     private final ZhiHuApi mZhiHuApi;
//     private final WeatherApi mWeatherApi;
// 
//     @Inject
//     protected Api(GankApi gankApi,ZhiHuApi zhiHuApi,WeatherApi weatherApi) {
//         mGankApi = gankApi;
//         mZhiHuApi = zhiHuApi;
//         mWeatherApi = weatherApi;
//     }
// 
//     // TODO: 16/7/29 compose
// 
//     public Observable<GankResponse> getAndroid(int page) {
//         return wrap(mGankApi.getAndroid(page));
//     }
// 
//     public Observable<GankResponse> getIos(int page) {
//         return wrap(mGankApi.getIos(page));
//     }
// 
// //    public Observable<List<GIosEntity>> getIos(int page) {
// //        return apply(mGankApi.getIos(page));
// //    }
// 
//     public Observable<GankResponse> getMeizi(int page) {
//         return wrap(mGankApi.getMeizi(page));
//     }
// 
//     public Observable<GankDaily> getDaily(int year, int month, int day) {
//         return mGankApi.getDaily(year, month, day);
//     }
// 
//     public Observable<SplashEntity> getWel() {
//         return wrap(mZhiHuApi.getWel());
//     }
// 
// 
//     public Observable<RequestBody> getWeather(String city) {
//         return wrap(mWeatherApi.getWeather(city));
//     }
// 
//     private  <T> Observable<T> wrap(Observable<T> o) {
//         return o.timeout(10_000,TimeUnit.MILLISECONDS)
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread());
//     }
// 
//     private <T> Observable<T> apply(Observable<RxResponse<T>> observable) {
//         return observable.timeout(10_000, TimeUnit.MILLISECONDS)
//                 .flatMap(new PickResults<>())
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread());
//     }
// 
//     private class PickResults<T> implements Func1<RxResponse<T>, Observable<T>> {
// 
//         @Override
//         public Observable<T> call(RxResponse<T> tRxResponse) {
//             return Observable.just(tRxResponse.results);
//         }
//     }
// }


import javax.inject.Singleton;
import dagger.Component;
import me.yifeiyuan.climb.di.modules.ApiModule;
import me.yifeiyuan.climb.network.api.Api;
/*
 * Copyright (C) 2016, 程序亦非猿
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.yifeiyuan.climb.di.components;



/**
 * Created by 程序亦非猿 on 16/10/18.
 */
@Singleton
@Component(modules = {ApiModule.class})
public interface ApiComponent {
// Path: app/src/main/java/me/yifeiyuan/climb/di/modules/ApiModule.java
// @Module
// public class ApiModule {
// 
//     @Singleton
//     @Provides
//     OkHttpClient provideOkHttpClient() {
//         OkHttpClient.Builder builder = new OkHttpClient.Builder()
//                 .connectTimeout(30_000, TimeUnit.MILLISECONDS)
//                 .readTimeout(30_000, TimeUnit.MILLISECONDS)
//                 .writeTimeout(30_000, TimeUnit.MILLISECONDS);
// 
//         if (BuildConfig.DEBUG) {
//             HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
//             logging.setLevel(HttpLoggingInterceptor.Level.BODY);
//             builder.addInterceptor(logging);
//         }
// 
//         return builder.build();
//     }
// 
//     @Singleton
//     @Provides
//     Gson provideGson() {
//         return new GsonBuilder()
//                 .setDateFormat("yyyy-MM-dd")   //("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
//                 .create();
//     }
// 
//     @Singleton
//     @Provides
//     Retrofit provideRetrofit(OkHttpClient client, Gson gson) {
//         Retrofit retrofit = new Retrofit.Builder()
//                 .baseUrl(GankConfig.URL_DOMAIN)
//                 .addConverterFactory(GsonConverterFactory.create(gson))
//                 .addCallAdapterFactory(RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io()))
//                 .client(client)
//                 .build();
// 
//         return retrofit;
//     }
// 
//     @Singleton
//     @Provides
//     GankApi provideGankApi(Retrofit retrofit) {
//         return retrofit.create(GankApi.class);
//     }
// 
//     @Singleton
//     @Provides
//     ZhiHuApi provideZhiHuApi(Retrofit retrofit) {
//         return retrofit.create(ZhiHuApi.class);
//     }
// 
//     @Singleton
//     @Provides
//     WeatherApi provideWeatherApi(Retrofit retrofit) {
//         return retrofit.create(WeatherApi.class);
//     }
// 
// }
// 
// Path: app/src/main/java/me/yifeiyuan/climb/network/api/Api.java
// public class Api {
// 
//     private final GankApi mGankApi;
//     private final ZhiHuApi mZhiHuApi;
//     private final WeatherApi mWeatherApi;
// 
//     @Inject
//     protected Api(GankApi gankApi,ZhiHuApi zhiHuApi,WeatherApi weatherApi) {
//         mGankApi = gankApi;
//         mZhiHuApi = zhiHuApi;
//         mWeatherApi = weatherApi;
//     }
// 
//     // TODO: 16/7/29 compose
// 
//     public Observable<GankResponse> getAndroid(int page) {
//         return wrap(mGankApi.getAndroid(page));
//     }
// 
//     public Observable<GankResponse> getIos(int page) {
//         return wrap(mGankApi.getIos(page));
//     }
// 
// //    public Observable<List<GIosEntity>> getIos(int page) {
// //        return apply(mGankApi.getIos(page));
// //    }
// 
//     public Observable<GankResponse> getMeizi(int page) {
//         return wrap(mGankApi.getMeizi(page));
//     }
// 
//     public Observable<GankDaily> getDaily(int year, int month, int day) {
//         return mGankApi.getDaily(year, month, day);
//     }
// 
//     public Observable<SplashEntity> getWel() {
//         return wrap(mZhiHuApi.getWel());
//     }
// 
// 
//     public Observable<RequestBody> getWeather(String city) {
//         return wrap(mWeatherApi.getWeather(city));
//     }
// 
//     private  <T> Observable<T> wrap(Observable<T> o) {
//         return o.timeout(10_000,TimeUnit.MILLISECONDS)
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread());
//     }
// 
//     private <T> Observable<T> apply(Observable<RxResponse<T>> observable) {
//         return observable.timeout(10_000, TimeUnit.MILLISECONDS)
//                 .flatMap(new PickResults<>())
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread());
//     }
// 
//     private class PickResults<T> implements Func1<RxResponse<T>, Observable<T>> {
// 
//         @Override
//         public Observable<T> call(RxResponse<T> tRxResponse) {
//             return Observable.just(tRxResponse.results);
//         }
//     }
// }


// Path: app/src/main/java/me/yifeiyuan/climb/di/components/ApiComponent.java
import javax.inject.Singleton;
import dagger.Component;
import me.yifeiyuan.climb.di.modules.ApiModule;
import me.yifeiyuan.climb.network.api.Api;

/*
 * Copyright (C) 2016, 程序亦非猿
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.yifeiyuan.climb.di.components;



/**
 * Created by 程序亦非猿 on 16/10/18.
 */
@Singleton
@Component(modules = {ApiModule.class})
public interface ApiComponent {
    Api api();