Search in sources :

Example 6 with MyHttpUtils

use of com.mnnyang.gzuclassschedule.data.http.MyHttpUtils in project GzuClassSchedule by mnnyang.

the class HomePresenter method downCourse.

/**
 * 下载course
 */
@Override
public void downCourse() {
    if (TextUtils.isEmpty(Cache.instance().getEmail())) {
        mView.pleaseLoginIn();
        return;
    }
    mView.showLoading("同步中");
    new MyHttpUtils().downCourse(new HttpCallback<DownCourseWrapper>() {

        @Override
        public void onSuccess(DownCourseWrapper bean) {
            if (mView == null) {
                // view被销毁
                return;
            }
            mView.stopLoading();
            if (bean != null) {
                if (bean.getCode() == 1) {
                    overWriteLocal(bean.getData());
                    mView.stopLoading();
                    EventBus.getDefault().post(new CourseDataChangeEvent());
                    mView.cloudToLocalSucceed();
                } else {
                    mView.showMassage("同步失败:" + bean.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) CourseDataChangeEvent(com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent) DownCourseWrapper(com.mnnyang.gzuclassschedule.data.beanv2.DownCourseWrapper)

Example 7 with MyHttpUtils

use of com.mnnyang.gzuclassschedule.data.http.MyHttpUtils 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

MyHttpUtils (com.mnnyang.gzuclassschedule.data.http.MyHttpUtils)7 BaseBean (com.mnnyang.gzuclassschedule.data.beanv2.BaseBean)3 DownCourseWrapper (com.mnnyang.gzuclassschedule.data.beanv2.DownCourseWrapper)2 CourseDataChangeEvent (com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent)2 Bitmap (android.graphics.Bitmap)1 ShareBean (com.mnnyang.gzuclassschedule.data.beanv2.ShareBean)1 UserWrapper (com.mnnyang.gzuclassschedule.data.beanv2.UserWrapper)1 HttpCallback (com.mnnyang.gzuclassschedule.data.http.HttpCallback)1 QRCode (com.mnnyang.gzuclassschedule.utils.spec.QRCode)1 Disposable (io.reactivex.disposables.Disposable)1 Function (io.reactivex.functions.Function)1 List (java.util.List)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1