use of org.edx.mobile.discussion.CourseDiscussionInfo in project edx-app-android by edx.
the class CourseDiscussionPostsThreadFragment method checkIfDiscussionsBlackedOut.
/**
* Query server to check if discussions on this course are blacked out.
*/
private void checkIfDiscussionsBlackedOut() {
setCreateNewPostBtnVisibility(View.GONE);
discussionService.getCourseDiscussionInfo(courseData.getCourse().getId()).enqueue(new ErrorHandlingCallback<CourseDiscussionInfo>(getContext(), (TaskProgressCallback) null) {
@Override
public void onFailure(@NonNull Call<CourseDiscussionInfo> call, @NonNull Throwable t) {
markAsBlackedOut(false);
}
@Override
protected void onResponse(@NonNull CourseDiscussionInfo discussionInfo) {
final Date today = new Date();
final List<TimePeriod> blackoutTimesList = discussionInfo.getBlackoutList();
for (TimePeriod timePeriod : blackoutTimesList) {
if (today.after(timePeriod.getStart()) && today.before(timePeriod.getEnd())) {
markAsBlackedOut(true);
return;
}
}
markAsBlackedOut(false);
}
private void markAsBlackedOut(boolean isBlackedOut) {
courseData.setDiscussionBlackedOut(isBlackedOut);
createNewPostLayout.setEnabled(!isBlackedOut);
setCreateNewPostBtnVisibility(View.VISIBLE);
}
});
}
Aggregations