Search in sources :

Example 6 with CourseDataChangeEvent

use of com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent 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)

Aggregations

CourseDataChangeEvent (com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent)6 DownCourseWrapper (com.mnnyang.gzuclassschedule.data.beanv2.DownCourseWrapper)2 MyHttpUtils (com.mnnyang.gzuclassschedule.data.http.MyHttpUtils)2 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 CourseV2 (com.mnnyang.gzuclassschedule.data.beanv2.CourseV2)1 DialogHelper (com.mnnyang.gzuclassschedule.utils.DialogHelper)1 DialogListener (com.mnnyang.gzuclassschedule.utils.DialogListener)1