Search in sources :

Example 1 with CourseDataChangeEvent

use of com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent in project GzuClassSchedule by mnnyang.

the class MgActivity method switchDialog.

private void switchDialog(final long tag) {
    DialogHelper dh = new DialogHelper();
    dh.showNormalDialog(this, getString(R.string.warning), "确认要切换到该课表吗?", new DialogListener() {

        @Override
        public void onPositive(DialogInterface dialog, int which) {
            super.onPositive(dialog, which);
            mPresenter.switchCsName(tag);
            EventBus.getDefault().post(new CourseDataChangeEvent());
            AppUtils.updateWidget(getBaseContext());
        }
    });
}
Also used : DialogHelper(com.mnnyang.gzuclassschedule.utils.DialogHelper) DialogInterface(android.content.DialogInterface) DialogListener(com.mnnyang.gzuclassschedule.utils.DialogListener) CourseDataChangeEvent(com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent)

Example 2 with CourseDataChangeEvent

use of com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent in project GzuClassSchedule by mnnyang.

the class AddActivity method submit.

private void submit() {
    // name
    String name = mEtlName.getText().trim();
    if (TextUtils.isEmpty(name)) {
        toast("课程名称不能为空!");
        return;
    }
    // teacher
    String teacher = mEtlTeacher.getText().trim();
    // group
    long couCgId = Preferences.getLong(getString(R.string.app_preference_current_cs_name_id), 0);
    int childCount = mLayoutLocationContainer.getChildCount();
    boolean hasLocation = false;
    for (int i = 0; i < childCount; i++) {
        View locationItem = mLayoutLocationContainer.getChildAt(i);
        Object obj = locationItem.getTag();
        if (obj != null) {
            hasLocation = true;
            CourseV2 courseV2 = (CourseV2) obj;
            courseV2.setCouName(name);
            courseV2.setCouTeacher(teacher);
            if (mAddMode || courseV2.getCouId() == null) {
                courseV2.setCouCgId(couCgId);
                courseV2.init();
                Cache.instance().getCourseV2Dao().insert(courseV2);
            } else {
                courseV2.init();
                Cache.instance().getCourseV2Dao().update(courseV2);
            }
        }
    }
    if (!hasLocation) {
        toast("没有设置课程时间!☆\\( ̄▽ ̄)/");
    }
    if (mAddMode) {
        toast("添加成功!☆\\( ̄▽ ̄)/");
    } else {
        toast("编辑成功!☆\\( ̄▽ ̄)/");
    }
    EventBus.getDefault().post(new CourseDataChangeEvent());
    finish();
}
Also used : CourseV2(com.mnnyang.gzuclassschedule.data.beanv2.CourseV2) CourseDataChangeEvent(com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with CourseDataChangeEvent

use of com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent in project GzuClassSchedule by mnnyang.

the class HomePresenter method downShare.

/**
 * 下载解析分享
 */
@Override
public void downShare(String url) {
    if (TextUtils.isEmpty(url)) {
        mView.showMassage("分享为空");
        return;
    }
    mView.showLoading("导入中");
    new MyHttpUtils().downShare(url, new HttpCallback<DownCourseWrapper>() {

        @Override
        public void onSuccess(DownCourseWrapper downCourseWrapper) {
            if (mView == null) {
                // view被销毁
                return;
            }
            mView.stopLoading();
            if (downCourseWrapper == null || downCourseWrapper.getData() == null) {
                mView.showMassage("导入数据为空");
                return;
            }
            long newGroupId = writeShare(downCourseWrapper.getData());
            // 通知更新
            // 切换到当前课表
            Preferences.putLong(app.mContext.getString(R.string.app_preference_current_cs_name_id), newGroupId);
            mView.showMassage("导入成功!");
            EventBus.getDefault().post(new CourseDataChangeEvent());
            mView.cloudToLocalSucceed();
        }

        @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 4 with CourseDataChangeEvent

use of com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent in project GzuClassSchedule by mnnyang.

the class ImptActivity method showSucceed.

@Override
public void showSucceed() {
    EventBus.getDefault().post(new CourseDataChangeEvent());
    AppUtils.updateWidget(this);
    ToastUtils.show("导入成功");
    Preferences.putString(Constant.XH, mXh);
    Intent intent = new Intent(this, CourseActivity.class);
    startActivity(intent);
    finish();
}
Also used : CourseDataChangeEvent(com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent) Intent(android.content.Intent)

Example 5 with CourseDataChangeEvent

use of com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent in project GzuClassSchedule by mnnyang.

the class MgActivity method deleteFinish.

@Override
public void deleteFinish() {
    mPresenter.reloadCsNameList();
    EventBus.getDefault().post(new CourseDataChangeEvent());
    AppUtils.updateWidget(this);
}
Also used : CourseDataChangeEvent(com.mnnyang.gzuclassschedule.utils.event.CourseDataChangeEvent)

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