use of com.mnnyang.gzuclassschedule.data.greendao.CourseGroupDao in project GzuClassSchedule by mnnyang.
the class MgPresenter method deleteCsName.
@Override
public void deleteCsName(final long csNameId) {
CourseGroupDao groupDao = Cache.instance().getCourseGroupDao();
groupDao.deleteByKey(csNameId);
if (mView == null) {
// 检查到view已经被销毁
return;
}
mView.deleteFinish();
}
use of com.mnnyang.gzuclassschedule.data.greendao.CourseGroupDao in project GzuClassSchedule by mnnyang.
the class HomePresenter method getGroupId.
/**
* 获取group_id
*/
private Long getGroupId(DownCourseWrapper.DownCourse downCourse) {
if (downCourse == null) {
return null;
}
CourseGroupDao groupDao = Cache.instance().getCourseGroupDao();
String groupName = downCourse.getGroup_name();
if (!TextUtils.isEmpty(groupName)) {
Long groupId = mCacheGroup.get(groupName);
if (null == groupId) {
CourseGroup dbGroup = groupDao.queryBuilder().where(CourseGroupDao.Properties.CgName.eq(groupName)).unique();
if (dbGroup == null) {
CourseGroup newGroup = new CourseGroup().setCgName(groupName);
groupId = groupDao.insert(newGroup);
} else {
groupId = dbGroup.getCgId();
}
mCacheGroup.put(groupName, groupId);
}
return groupId;
} else {
LogUtil.e(this, "下载的数据未找到group_name");
return null;
}
}
use of com.mnnyang.gzuclassschedule.data.greendao.CourseGroupDao in project GzuClassSchedule by mnnyang.
the class CourseActivity method initFirstStart.
@Override
public void initFirstStart() {
boolean isFirst = Preferences.getBoolean(getString(R.string.app_preference_app_is_first_start), true);
if (!isFirst) {
return;
}
Preferences.putBoolean(getString(R.string.app_preference_app_is_first_start), false);
CourseGroupDao groupDao = Cache.instance().getCourseGroupDao();
CourseGroup defaultGroup = groupDao.queryBuilder().where(CourseGroupDao.Properties.CgName.eq("默认课表")).unique();
long insert;
if (defaultGroup == null) {
insert = groupDao.insert(new CourseGroup(0L, "默认", ""));
} else {
insert = defaultGroup.getCgId();
}
// migrate old data
AppUtils.copyOldData(this);
Preferences.putLong(getString(R.string.app_preference_current_cs_name_id), insert);
showOnceSplash();
}
use of com.mnnyang.gzuclassschedule.data.greendao.CourseGroupDao in project GzuClassSchedule by mnnyang.
the class MgPresenter method addCsName.
@Override
public void addCsName(String csName) {
if (mView == null) {
// 检查到view已经被销毁
return;
}
if (TextUtils.isEmpty(csName)) {
mView.showNotice(app.mContext.getString(R.string.course_name_can_not_be_empty));
} else {
// TODO 检查
CourseGroupDao groupDao = Cache.instance().getCourseGroupDao();
CourseGroup group = groupDao.queryBuilder().where(CourseGroupDao.Properties.CgName.eq(csName)).unique();
if (group != null) {
// notice conflict
mView.showNotice(app.mContext.getString(R.string.course_name_is_conflicting));
} else {
// add cs_name
groupDao.insert(new CourseGroup(null, csName, null));
mView.addCsNameSucceed();
}
}
}
use of com.mnnyang.gzuclassschedule.data.greendao.CourseGroupDao in project GzuClassSchedule by mnnyang.
the class MgPresenter method editCsName.
@Override
public void editCsName(long id, String newCsName) {
CourseGroupDao groupDao = Cache.instance().getCourseGroupDao();
if (mView == null) {
// 检查到view已经被销毁
return;
}
CourseGroup group = groupDao.queryBuilder().where(CourseGroupDao.Properties.CgName.eq(newCsName)).unique();
if (group != null) {
// notice conflict
mView.showNotice(app.mContext.getString(R.string.course_name_is_conflicting));
return;
}
Cache.instance().getCourseGroupDao().update(new CourseGroup(id, newCsName, null));
mView.editCsNameSucceed();
}
Aggregations