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());
}
});
}
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();
}
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);
}
});
}
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();
}
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);
}
Aggregations