// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java
// public class PreferencesManager {
//     public static final String PREFERENCES_NAME = "androidarchitecture";
//     private SharedPreferences sharedPreferences;
// 
// 
//     public PreferencesManager(Application application){
//         sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
//     }
// 
//     public void saveLoginInfo(String username,String password){
//         SharedPreferences.Editor editor = sharedPreferences.edit();
//         editor.putString("username",username);
//         editor.putString("password",password);
//         editor.commit();
//     }
// 
// 
// 
//     public String getUserName(){
//         return sharedPreferences.getString("username","");
//     }
// 
//     public String getPassword(){
//         return sharedPreferences.getString("password","");
//     }
// 
// }
// 
// 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/SimpleCallback.java
// public interface SimpleCallback<T> {
//     void onStart();
//     void onNext(T t);
//     void onComplete();
// }
// 
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java
// public class User {
// }


import android.app.Activity;
import com.zhy.authproject.data.local.PreferencesManager;
import com.zhy.authproject.data.remote.ApiManager;
import com.zhy.authproject.data.remote.SimpleCallback;
import com.zhy.authproject.data.remote.model.User;
package com.zhy.authproject.module.login;



/**
 * Created by zhanghaoye on 10/21/16.
 */

public class LoginPresenter {
    private final LoginView loginView;
    private final ApiManager apiManager;
    private final PreferencesManager preferencesManager;

    public LoginPresenter(LoginView loginView,ApiManager apiManager, PreferencesManager preferencesManager) {
        this.loginView = loginView;
        this.apiManager = apiManager;
        this.preferencesManager = preferencesManager;
    }



    public void login(final String username, final String password) {
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/local/PreferencesManager.java
// public class PreferencesManager {
//     public static final String PREFERENCES_NAME = "androidarchitecture";
//     private SharedPreferences sharedPreferences;
// 
// 
//     public PreferencesManager(Application application){
//         sharedPreferences = application.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
//     }
// 
//     public void saveLoginInfo(String username,String password){
//         SharedPreferences.Editor editor = sharedPreferences.edit();
//         editor.putString("username",username);
//         editor.putString("password",password);
//         editor.commit();
//     }
// 
// 
// 
//     public String getUserName(){
//         return sharedPreferences.getString("username","");
//     }
// 
//     public String getPassword(){
//         return sharedPreferences.getString("password","");
//     }
// 
// }
// 
// 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/SimpleCallback.java
// public interface SimpleCallback<T> {
//     void onStart();
//     void onNext(T t);
//     void onComplete();
// }
// 
// Path: AuthProject/app/src/main/java/com/zhy/authproject/data/remote/model/User.java
// public class User {
// }


// Path: AuthProject/app/src/main/java/com/zhy/authproject/module/login/LoginPresenter.java
import android.app.Activity;
import com.zhy.authproject.data.local.PreferencesManager;
import com.zhy.authproject.data.remote.ApiManager;
import com.zhy.authproject.data.remote.SimpleCallback;
import com.zhy.authproject.data.remote.model.User;

package com.zhy.authproject.module.login;



/**
 * Created by zhanghaoye on 10/21/16.
 */

public class LoginPresenter {
    private final LoginView loginView;
    private final ApiManager apiManager;
    private final PreferencesManager preferencesManager;

    public LoginPresenter(LoginView loginView,ApiManager apiManager, PreferencesManager preferencesManager) {
        this.loginView = loginView;
        this.apiManager = apiManager;
        this.preferencesManager = preferencesManager;
    }



    public void login(final String username, final String password) {
        apiManager.login((Activity) loginView, username, password, new SimpleCallback<User>() {