82 lines
3.1 KiB
Java
82 lines
3.1 KiB
Java
package com.ubt.jimu.base.db.starcourse;
|
|
|
|
import com.ubt.jimu.JimuApplication;
|
|
import com.ubt.jimu.base.db.DatabaseUtils;
|
|
import com.ubt.jimu.base.entities.Constant;
|
|
import com.ubt.jimu.base.entities.Course;
|
|
import com.ubt.jimu.gen.CourseDao;
|
|
import com.ubt.jimu.utils.LogUtils;
|
|
import com.ubt.jimu.utils.SPUtils;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import org.greenrobot.greendao.query.QueryBuilder;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class CourseDbHandler {
|
|
public static List<Course> getNewCourseList() {
|
|
ArrayList arrayList = new ArrayList();
|
|
CourseDao c = DatabaseUtils.getDaoSession(true).c();
|
|
String g = JimuApplication.l().g();
|
|
QueryBuilder<Course> k = c.k();
|
|
k.a(CourseDao.Properties.Lan.a((Object) g), CourseDao.Properties.StoryName.a((Object) Constant.SelectRobot.ASTROBOT_MINI));
|
|
List<Course> b = k.b();
|
|
arrayList.addAll(b);
|
|
LogUtils.c("tList.getNewCourseList" + b.size());
|
|
return arrayList;
|
|
}
|
|
|
|
public static List<Course> getOldCourseList() {
|
|
ArrayList arrayList = new ArrayList();
|
|
CourseDao c = DatabaseUtils.getDaoSession(true).c();
|
|
String g = JimuApplication.l().g();
|
|
QueryBuilder<Course> k = c.k();
|
|
k.a(CourseDao.Properties.Lan.a((Object) g), CourseDao.Properties.StoryName.a((Object) "AstroBot"));
|
|
arrayList.addAll(k.b());
|
|
return arrayList;
|
|
}
|
|
|
|
public static void saveList(List<Course> list) {
|
|
if (list == null || list.size() == 0) {
|
|
return;
|
|
}
|
|
CourseDao c = DatabaseUtils.getDaoSession(true).c();
|
|
String g = JimuApplication.l().g();
|
|
Iterator<Course> it = list.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().setLan(g);
|
|
}
|
|
c.c((Iterable) list);
|
|
}
|
|
|
|
public static void setCourseComplete(Course course) {
|
|
if (course == null) {
|
|
return;
|
|
}
|
|
CourseDao c = DatabaseUtils.getDaoSession(true).c();
|
|
String g = JimuApplication.l().g();
|
|
course.setLan(g);
|
|
course.setStatus(Course.STATUS_COMPLETED);
|
|
c.j(course);
|
|
String b = SPUtils.b(Constant.SelectRobot.INTERSTELLAR_ADVENTURE_SELECT_PACKAGE_KEY);
|
|
List<Course> oldCourseList = (Constant.SelectRobot.INTERSTELLAR_ADVENTURE_OLD_PACKAGE_CN.equals(b) || Constant.SelectRobot.INTERSTELLAR_ADVENTURE_OLD_PACKAGE_NA.equals(b) || Constant.SelectRobot.INTERSTELLAR_ADVENTURE_OLD_PACKAGE_GLOBAL.equals(b)) ? getOldCourseList() : getNewCourseList();
|
|
Course course2 = null;
|
|
boolean z = false;
|
|
for (int i = 0; i < oldCourseList.size(); i++) {
|
|
Course course3 = oldCourseList.get(i);
|
|
if (course3.getNameKey().equals(course.getNextCourse())) {
|
|
course2 = course3;
|
|
}
|
|
if (course3.getStatus().equals(Course.STATUS_RUNNING)) {
|
|
z = true;
|
|
}
|
|
}
|
|
if (z || course2 == null) {
|
|
return;
|
|
}
|
|
course2.setStatus(Course.STATUS_RUNNING);
|
|
course2.setLan(g);
|
|
c.b((Object[]) new Course[]{course2});
|
|
}
|
|
}
|