No lecturers fix
This commit is contained in:
@@ -278,6 +278,12 @@ public class ModulesList extends HTTPService {
|
|||||||
if (--latch[0] == 0) successCallback.onResponse(modulesKVV);
|
if (--latch[0] == 0) successCallback.onResponse(modulesKVV);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Modules.Module bbCourse = cacheBBCourse().getBBCourse(courseId);
|
||||||
|
if (bbCourse != null) {
|
||||||
|
modulesKVV.addModule(bbCourse);
|
||||||
|
if (--latch[0] == 0) successCallback.onResponse(modulesKVV);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
get(String.format("https://lms.fu-berlin.de/learn/api/v1/courses/%s?fields=name,courseId,description", courseId), mLogin.getLoginTokenBB().getCookies(), response1 -> {
|
get(String.format("https://lms.fu-berlin.de/learn/api/v1/courses/%s?fields=name,courseId,description", courseId), mLogin.getLoginTokenBB().getCookies(), response1 -> {
|
||||||
String body1 = response1.getParsed();
|
String body1 = response1.getParsed();
|
||||||
if (body1 == null) {
|
if (body1 == null) {
|
||||||
@@ -313,7 +319,8 @@ public class ModulesList extends HTTPService {
|
|||||||
Semester finalSemester = semester;
|
Semester finalSemester = semester;
|
||||||
String finalType = type;
|
String finalType = type;
|
||||||
lecturer().getBBLecturers(courseId, success -> {
|
lecturer().getBBLecturers(courseId, success -> {
|
||||||
modulesKVV.addModule(finalSemester, lvNumberSet, name, success, finalType, description, courseId, Modules.TYPE_BB);
|
Modules.Module module = modulesKVV.addModule(finalSemester, lvNumberSet, name, success, finalType, description, courseId, Modules.TYPE_BB);
|
||||||
|
cacheBBCourse().setBBCourse(courseId, module);
|
||||||
if (--latch[0] == 0) successCallback.onResponse(modulesKVV);
|
if (--latch[0] == 0) successCallback.onResponse(modulesKVV);
|
||||||
}, error -> {
|
}, error -> {
|
||||||
log.e(error);
|
log.e(error);
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
|
||||||
import de.sebse.fuplanner.services.kvv.types.Lecturer;
|
|
||||||
import de.sebse.fuplanner.services.kvv.types.CacheLecturer;
|
import de.sebse.fuplanner.services.kvv.types.CacheLecturer;
|
||||||
|
import de.sebse.fuplanner.services.kvv.types.Lecturer;
|
||||||
import de.sebse.fuplanner.tools.network.HTTPService;
|
import de.sebse.fuplanner.tools.network.HTTPService;
|
||||||
import de.sebse.fuplanner.tools.network.NetworkCallback;
|
import de.sebse.fuplanner.tools.network.NetworkCallback;
|
||||||
import de.sebse.fuplanner.tools.network.NetworkError;
|
import de.sebse.fuplanner.tools.network.NetworkError;
|
||||||
@@ -53,6 +53,8 @@ class ModulesListLecturer extends HTTPService {
|
|||||||
if (--latch[0] == 0) callback.onResponse(lecturers);
|
if (--latch[0] == 0) callback.onResponse(lecturers);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (lecturerString.size() == 0)
|
||||||
|
callback.onResponse(lecturers);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.io.IOException;
|
|||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class CacheBBCourse implements Serializable {
|
public class CacheBBCourse implements Serializable {
|
||||||
@@ -18,6 +19,8 @@ public class CacheBBCourse implements Serializable {
|
|||||||
|
|
||||||
private HashSet<String> mKVVCourseList = new HashSet<>();
|
private HashSet<String> mKVVCourseList = new HashSet<>();
|
||||||
private long mKVVCourseListRefresh = 0;
|
private long mKVVCourseListRefresh = 0;
|
||||||
|
private HashMap<String, Modules.Module> mBBCourseList = new HashMap<>();
|
||||||
|
private HashMap<String, Long> mBBCourseListRefresh = new HashMap<>();
|
||||||
|
|
||||||
public static CacheBBCourse load(Context context) throws IOException, ClassNotFoundException {
|
public static CacheBBCourse load(Context context) throws IOException, ClassNotFoundException {
|
||||||
FileInputStream fis = context.openFileInput(FILE_NAME);
|
FileInputStream fis = context.openFileInput(FILE_NAME);
|
||||||
@@ -72,4 +75,18 @@ public class CacheBBCourse implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
return mKVVCourseList.contains(courseID);
|
return mKVVCourseList.contains(courseID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBBCourse(String courseID, Modules.Module lecturer) {
|
||||||
|
mBBCourseList.put(courseID, lecturer);
|
||||||
|
mBBCourseListRefresh.put(courseID, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Modules.Module getBBCourse(String courseID) {
|
||||||
|
if (!mBBCourseListRefresh.containsKey(courseID))
|
||||||
|
return null;
|
||||||
|
//noinspection ConstantConditions
|
||||||
|
if (mBBCourseListRefresh.get(courseID) + RESAVE_TIMER < System.currentTimeMillis())
|
||||||
|
return null;
|
||||||
|
return mBBCourseList.get(courseID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,14 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
|
|||||||
this.list = new SortedListModule();
|
this.list = new SortedListModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addModule(@Nullable Semester semester, HashSet<String> lvNumber, String title, LinkedHashSet<Lecturer> lecturer, String type, String description, String ID, int moduleType) {
|
public Module addModule(@Nullable Semester semester, HashSet<String> lvNumber, String title, LinkedHashSet<Lecturer> lecturer, String type, String description, String ID, int moduleType) {
|
||||||
Module m = new Module(semester, lvNumber, title, lecturer, type, description, ID, moduleType);
|
Module m = new Module(semester, lvNumber, title, lecturer, type, description, ID, moduleType);
|
||||||
this.list.add(m);
|
this.list.add(m);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addModule(Module module) {
|
||||||
|
this.list.add(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -224,5 +229,9 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
|
|||||||
public int getModuleType() {
|
public int getModuleType() {
|
||||||
return moduleType;
|
return moduleType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Module clone() {
|
||||||
|
return new Module(semester, lvNumber, title, new LinkedHashSet<>(lecturer), type, description, ID, moduleType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user