// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// public class ApiManager {
//     private final ApiService apiService;
// 
//     private final Application application;
// 
//     public ApiManager(ApiService apiService, Application application) {
//         this.apiService = apiService;
//         this.application = application;
//     }
// 
//     //登录
//     public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){
//         apiService.login(username,password)
//                 .flatMap(new BaseResponseFunc<User>())
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow));
//     }
// 
//    //获取活动列表
//     public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){
//         apiService.getActivityInfo(id,user_id,access_token)
//                 .flatMap(new BaseResponseFunc<ActivityInfo>())
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context));
//     }
// 
//     //修改活动信息
//     public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){
//         apiService.modifyActivity(activity_id,user_id,access_token)
//                 .flatMap(new BaseResponseFunc<CommonInfo>())
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context));
//     }
// 
// 
// }
// 
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java
// public interface ApiService {
//     String SERVER_URL = "http://127.0.0.1:3000/";
// 
//     @FormUrlEncoded
//     @POST("/api/v1/authproject/login")
//     Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password);
// 
//     @FormUrlEncoded
//     @POST("/api/v1/authproject/{id}/modify_activity")
//     Observable<BaseResponse<CommonInfo>> modifyActivity(@Path("id")String id,@Field("user_id") String user_id, @Field("access_token") String access_token);
// 
//     @GET("/api/v1/authproject/{id}")
//     Observable<BaseResponse<ActivityInfo>> getActivityInfo(@Path("id")String id,String user_id,@Query("access_token") String access_token);
// 
// }


import android.app.Application;
import com.zhy.authproject.BuildConfig;
import com.zhy.authproject.data.remote.ApiManager;
import com.zhy.authproject.data.remote.ApiService;
import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
package com.zhy.authproject.di;






/**
 * Created by zhanghaoye on 10/24/16.
 */
@Module
public class ApiModule {
    @Provides
    @Singleton
    public OkHttpClient provideOkHttpClient() {
        final OkHttpClient.Builder builder = new OkHttpClient.Builder();

        if (BuildConfig.DEBUG) {
            HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
            logging.setLevel(HttpLoggingInterceptor.Level.BODY);
            builder.addInterceptor(logging);
        }

        builder.connectTimeout(60 * 1000, TimeUnit.MILLISECONDS)
                .readTimeout(60 * 1000, TimeUnit.MILLISECONDS);

        return builder.build();
    }

    @Provides
    @Singleton
    public Retrofit provideRestAdapter(OkHttpClient okHttpClient) {
        Retrofit.Builder builder = new Retrofit.Builder();
        builder.client(okHttpClient)
                .baseUrl(ApiService.SERVER_URL)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create());
        return builder.build();
    }

    @Provides
    @Singleton
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiManager.java
// public class ApiManager {
//     private final ApiService apiService;
// 
//     private final Application application;
// 
//     public ApiManager(ApiService apiService, Application application) {
//         this.apiService = apiService;
//         this.application = application;
//     }
// 
//     //登录
//     public void login(Context context,String username, String password, SimpleCallback<User> simpleCallback,boolean isShow){
//         apiService.login(username,password)
//                 .flatMap(new BaseResponseFunc<User>())
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(new ExceptionSubscriber<User>(simpleCallback,application,context,isShow));
//     }
// 
//    //获取活动列表
//     public void getActivities(Context context,String id,String user_id,String access_token,SimpleCallback<ActivityInfo> simpleCallback){
//         apiService.getActivityInfo(id,user_id,access_token)
//                 .flatMap(new BaseResponseFunc<ActivityInfo>())
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(new ExceptionSubscriber<ActivityInfo>(simpleCallback,application,context));
//     }
// 
//     //修改活动信息
//     public void modifyActivity(Context context,String activity_id,String user_id, String access_token,SimpleCallback<CommonInfo> simpleCallback){
//         apiService.modifyActivity(activity_id,user_id,access_token)
//                 .flatMap(new BaseResponseFunc<CommonInfo>())
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(new ExceptionSubscriber<CommonInfo>(simpleCallback,application,context));
//     }
// 
// 
// }
// 
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/ApiService.java
// public interface ApiService {
//     String SERVER_URL = "http://127.0.0.1:3000/";
// 
//     @FormUrlEncoded
//     @POST("/api/v1/authproject/login")
//     Observable<BaseResponse<User>> login(@Field("phone") String username, @Field("password") String password);
// 
//     @FormUrlEncoded
//     @POST("/api/v1/authproject/{id}/modify_activity")
//     Observable<BaseResponse<CommonInfo>> modifyActivity(@Path("id")String id,@Field("user_id") String user_id, @Field("access_token") String access_token);
// 
//     @GET("/api/v1/authproject/{id}")
//     Observable<BaseResponse<ActivityInfo>> getActivityInfo(@Path("id")String id,String user_id,@Query("access_token") String access_token);
// 
// }


// Path: AuthProject/app/src/main/java/com/zhy/authproject/di/ApiModule.java
import android.app.Application;
import com.zhy.authproject.BuildConfig;
import com.zhy.authproject.data.remote.ApiManager;
import com.zhy.authproject.data.remote.ApiService;
import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

package com.zhy.authproject.di;






/**
 * Created by zhanghaoye on 10/24/16.
 */
@Module
public class ApiModule {
    @Provides
    @Singleton
    public OkHttpClient provideOkHttpClient() {
        final OkHttpClient.Builder builder = new OkHttpClient.Builder();

        if (BuildConfig.DEBUG) {
            HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
            logging.setLevel(HttpLoggingInterceptor.Level.BODY);
            builder.addInterceptor(logging);
        }

        builder.connectTimeout(60 * 1000, TimeUnit.MILLISECONDS)
                .readTimeout(60 * 1000, TimeUnit.MILLISECONDS);

        return builder.build();
    }

    @Provides
    @Singleton
    public Retrofit provideRestAdapter(OkHttpClient okHttpClient) {
        Retrofit.Builder builder = new Retrofit.Builder();
        builder.client(okHttpClient)
                .baseUrl(ApiService.SERVER_URL)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create());
        return builder.build();
    }

    @Provides
    @Singleton
    public ApiService provideApiService(Retrofit restAdapter) {