use of org.edx.mobile.model.api.EnrolledCoursesResponse in project edx-app-android by edx.
the class MyCoursesListFragment method onLoadFinished.
@Override
public void onLoadFinished(Loader<AsyncTaskResult<List<EnrolledCoursesResponse>>> asyncTaskResultLoader, AsyncTaskResult<List<EnrolledCoursesResponse>> result) {
adapter.clear();
final Exception exception = result.getEx();
if (exception != null) {
if (exception instanceof AuthException) {
loginPrefs.clear();
getActivity().finish();
} else if (exception instanceof HttpStatusException) {
final HttpStatusException httpStatusException = (HttpStatusException) exception;
switch(httpStatusException.getStatusCode()) {
case HttpStatus.UNAUTHORIZED:
{
environment.getRouter().forceLogout(getContext(), environment.getAnalyticsRegistry(), environment.getNotificationDelegate());
break;
}
}
} else {
logger.error(exception);
}
errorNotification.showError(getActivity(), exception, R.string.lbl_reload, new View.OnClickListener() {
@Override
public void onClick(View v) {
if (NetworkUtil.isConnected(getContext())) {
onRefresh();
}
}
});
} else if (result.getResult() != null) {
ArrayList<EnrolledCoursesResponse> newItems = new ArrayList<EnrolledCoursesResponse>(result.getResult());
updateDatabaseAfterDownload(newItems);
if (result.getResult().size() > 0) {
adapter.setItems(newItems);
adapter.notifyDataSetChanged();
}
if (adapter.isEmpty() && !environment.getConfig().getCourseDiscoveryConfig().isCourseDiscoveryEnabled()) {
errorNotification.showError(R.string.no_courses_to_display, FontAwesomeIcons.fa_exclamation_circle, 0, null);
binding.myCourseList.setVisibility(View.GONE);
} else {
binding.myCourseList.setVisibility(View.VISIBLE);
errorNotification.hideError();
}
}
binding.swipeContainer.setRefreshing(false);
binding.loadingIndicator.getRoot().setVisibility(View.GONE);
if (!EventBus.getDefault().isRegistered(MyCoursesListFragment.this)) {
EventBus.getDefault().registerSticky(MyCoursesListFragment.this);
}
}
use of org.edx.mobile.model.api.EnrolledCoursesResponse in project edx-app-android by edx.
the class NewCourseOutlineActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// We don't need the drawer here
blockDrawerFromOpening();
if (courseComponentId == null) {
EnrolledCoursesResponse courseData = (EnrolledCoursesResponse) courseBundle.getSerializable(Router.EXTRA_COURSE_DATA);
environment.getAnalyticsRegistry().trackScreenView(isVideoMode ? Analytics.Screens.VIDEOS_COURSE_VIDEOS : Analytics.Screens.COURSE_OUTLINE, courseData.getCourse().getId(), null);
setTitle(courseData.getCourse().getName());
}
}
use of org.edx.mobile.model.api.EnrolledCoursesResponse in project edx-app-android by edx.
the class ApiTests method testSyncLastSubsection.
// TODO: Debug and fix test failure
@Ignore
@Test
public void testSyncLastSubsection() throws Exception {
login();
EnrolledCoursesResponse e = executeStrict(courseAPI.getEnrolledCourses()).get(0);
Map<String, SectionEntry> map = courseAPI.getCourseHierarchy(e.getCourse().getId());
Entry<String, SectionEntry> entry = map.entrySet().iterator().next();
Entry<String, ArrayList<VideoResponseModel>> subsection = entry.getValue().sections.entrySet().iterator().next();
String courseId = e.getCourse().getId();
String lastVisitedModuleId = subsection.getValue().get(0).getSection().getId();
assertNotNull(courseId);
assertNotNull(lastVisitedModuleId);
print(String.format("course= %s ; sub-section= %s", courseId, lastVisitedModuleId));
// TODO: lastVisitedModuleId must be section.id (id is now available)
SyncLastAccessedSubsectionResponse model = executeStrict(courseAPI.syncLastAccessedSubsection(courseId, lastVisitedModuleId));
assertNotNull(model);
print("sync returned: " + model.last_visited_module_id);
}
use of org.edx.mobile.model.api.EnrolledCoursesResponse in project edx-app-android by edx.
the class ApiTests method testGetLastAccessedModule.
// TODO: Debug and fix test failure
@Ignore
@Test
public void testGetLastAccessedModule() throws Exception {
login();
EnrolledCoursesResponse e = executeStrict(courseAPI.getEnrolledCourses()).get(0);
String courseId = e.getCourse().getId();
assertNotNull(courseId);
print(String.format("course= %s", courseId));
SyncLastAccessedSubsectionResponse model = executeStrict(courseAPI.getLastAccessedSubsection(courseId));
assertNotNull(model);
// print(model.json);
}
use of org.edx.mobile.model.api.EnrolledCoursesResponse in project edx-app-android by edx.
the class ApiTests method testCourseStructure.
// TODO: Debug and fix test failure
@Ignore
@Test
public void testCourseStructure() throws Exception {
login();
// get a course id for this test
List<EnrolledCoursesResponse> courses = executeStrict(courseAPI.getEnrolledCourses());
assertTrue("Must have enrolled to at least one course", courses != null && courses.size() > 0);
String courseId = courses.get(0).getCourse().getId();
Map<String, SectionEntry> chapters = courseAPI.getCourseHierarchy(courseId);
for (Entry<String, SectionEntry> entry : chapters.entrySet()) {
print("---------------" + entry.getKey() + "---------------");
for (Entry<String, ArrayList<VideoResponseModel>> se : entry.getValue().sections.entrySet()) {
print("------------" + se.getKey() + "------------");
for (VideoResponseModel v : se.getValue()) {
print(v.getSummary().getDisplayName());
}
}
}
}
Aggregations