Search in sources :

Example 1 with BaseBean

use of com.mnnyang.gzuclassschedule.data.beanv2.BaseBean in project GzuClassSchedule by mnnyang.

the class SignPresenter method signIn.

@Override
public void signIn(String email, String password) {
    if (mView == null) {
        // 检查到view已经被销毁
        return;
    }
    if (isOkOfVerifyInput(email, password)) {
        return;
    }
    mView.showLoading("登录中");
    email = email.trim();
    password = password.trim();
    new MyHttpUtils().login(email, password, new HttpCallback<BaseBean>() {

        @Override
        public void onSuccess(BaseBean baseBean) {
            if (mView == null) {
                // 检查到view已经被销毁
                return;
            }
            mView.stopLoading();
            if (baseBean != null) {
                if (baseBean.getCode() == 1) {
                    mView.signInSucceed(baseBean);
                } else {
                    mView.signInFailed(baseBean.getMsg());
                }
            } else {
                mView.showMassage("返回的数据有误!");
            }
        }

        @Override
        public void onFail(String errMsg) {
            if (mView == null) {
                // 检查到view已经被销毁
                return;
            }
            mView.stopLoading();
            mView.showMassage(errMsg);
        }
    });
}
Also used : MyHttpUtils(com.mnnyang.gzuclassschedule.data.http.MyHttpUtils) BaseBean(com.mnnyang.gzuclassschedule.data.beanv2.BaseBean)

Example 2 with BaseBean

use of com.mnnyang.gzuclassschedule.data.beanv2.BaseBean in project GzuClassSchedule by mnnyang.

the class HomePresenter method uploadCourse.

/**
 * 上传
 */
@Override
public void uploadCourse() {
    if (TextUtils.isEmpty(Cache.instance().getEmail())) {
        mView.pleaseLoginIn();
        return;
    }
    mView.showLoading("同步中");
    JSONObject result = buildJsonOfAllCourse();
    MyHttpUtils utils = new MyHttpUtils();
    utils.uploadCourse(result.toString(), new HttpCallback<BaseBean>() {

        @Override
        public void onSuccess(BaseBean baseBean) {
            if (mView == null) {
                // view被销毁
                return;
            }
            mView.stopLoading();
            if (baseBean != null) {
                if (baseBean.getCode() == 1) {
                    mView.showMassage("同步成功");
                } else {
                    mView.showMassage("同步失败:" + baseBean.getMsg());
                }
            } else {
                mView.showMassage("同步失败");
            }
        }

        @Override
        public void onFail(String errMsg) {
            if (mView == null) {
                // view被销毁
                return;
            }
            mView.stopLoading();
            mView.showMassage(errMsg);
        }
    });
}
Also used : MyHttpUtils(com.mnnyang.gzuclassschedule.data.http.MyHttpUtils) JSONObject(org.json.JSONObject) BaseBean(com.mnnyang.gzuclassschedule.data.beanv2.BaseBean)

Example 3 with BaseBean

use of com.mnnyang.gzuclassschedule.data.beanv2.BaseBean in project GzuClassSchedule by mnnyang.

the class SignPresenter method signUp.

@Override
public void signUp(String email, String password) {
    if (mView == null) {
        // 检查到view已经被销毁
        return;
    }
    if (isOkOfVerifyInput(email, password)) {
        return;
    }
    mView.showLoading("注册中");
    email = email.trim();
    password = password.trim();
    new MyHttpUtils().register(email, password, new HttpCallback<BaseBean>() {

        @Override
        public void onSuccess(BaseBean baseBean) {
            if (mView == null) {
                // 检查到view已经被销毁
                return;
            }
            mView.stopLoading();
            if (baseBean != null) {
                if (baseBean.getCode() == 1) {
                    mView.signUpSucceed(baseBean);
                } else {
                    mView.signUpFailed(baseBean.getMsg());
                }
            }
        }

        @Override
        public void onFail(String errMsg) {
            if (mView == null) {
                // 检查到view已经被销毁
                return;
            }
            mView.stopLoading();
            mView.signUpFailed(errMsg);
        }
    });
}
Also used : MyHttpUtils(com.mnnyang.gzuclassschedule.data.http.MyHttpUtils) BaseBean(com.mnnyang.gzuclassschedule.data.beanv2.BaseBean)

Aggregations

BaseBean (com.mnnyang.gzuclassschedule.data.beanv2.BaseBean)3 MyHttpUtils (com.mnnyang.gzuclassschedule.data.http.MyHttpUtils)3 JSONObject (org.json.JSONObject)1