Initial commit
This commit is contained in:
81
sources/com/ubt/jimu/base/db/starcourse/CourseDbHandler.java
Normal file
81
sources/com/ubt/jimu/base/db/starcourse/CourseDbHandler.java
Normal file
@@ -0,0 +1,81 @@
|
||||
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});
|
||||
}
|
||||
}
|
41
sources/com/ubt/jimu/base/db/starcourse/StoryDbHandler.java
Normal file
41
sources/com/ubt/jimu/base/db/starcourse/StoryDbHandler.java
Normal file
@@ -0,0 +1,41 @@
|
||||
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.Story;
|
||||
import com.ubt.jimu.gen.StoryDao;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.greenrobot.greendao.query.QueryBuilder;
|
||||
import org.greenrobot.greendao.query.WhereCondition;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StoryDbHandler {
|
||||
public static List<Story> getStoryList() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
try {
|
||||
String g = JimuApplication.l().g();
|
||||
QueryBuilder<Story> k = DatabaseUtils.getDaoSession(true).u().k();
|
||||
k.a(StoryDao.Properties.Lan.a((Object) g), new WhereCondition[0]);
|
||||
arrayList.addAll(k.b());
|
||||
return arrayList;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return arrayList;
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(List<Story> list) {
|
||||
if (list == null || list.size() == 0) {
|
||||
return;
|
||||
}
|
||||
String g = JimuApplication.l().g();
|
||||
StoryDao u = DatabaseUtils.getDaoSession(true).u();
|
||||
Iterator<Story> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().setLan(g);
|
||||
}
|
||||
u.c((Iterable) list);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user