use of org.edx.mobile.view.common.TaskMessageCallback in project edx-app-android by edx.
the class CourseDetailFragment method populateAboutThisCourse.
/**
* Makes a call the the course details api and sets the overview if given. If there is no
* overview, remove the courseAbout view.
*/
private void populateAboutThisCourse() {
getCourseDetailCall = courseApi.getCourseDetail(courseDetail.course_id);
final Activity activity = getActivity();
final TaskProgressCallback pCallback = activity instanceof TaskProgressCallback ? (TaskProgressCallback) activity : null;
final TaskMessageCallback mCallback = activity instanceof TaskMessageCallback ? (TaskMessageCallback) activity : null;
getCourseDetailCall.enqueue(new ErrorHandlingCallback<CourseDetail>(getActivity(), pCallback, mCallback, CallTrigger.LOADING_CACHED) {
@Override
protected void onResponse(@NonNull final CourseDetail courseDetail) {
if (courseDetail.overview != null && !courseDetail.overview.isEmpty()) {
populateAboutThisCourse(courseDetail.overview);
} else {
courseAbout.setVisibility(View.GONE);
}
}
});
}
use of org.edx.mobile.view.common.TaskMessageCallback in project edx-app-android by edx.
the class CourseDiscussionResponsesFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final Activity activity = getActivity();
responsesLoader = new ResponsesLoader(activity, discussionThread.getIdentifier(), discussionThread.getType() == DiscussionThread.ThreadType.QUESTION);
courseDiscussionResponsesAdapter = new CourseDiscussionResponsesAdapter(activity, this, this, discussionThread, courseData);
controller = InfiniteScrollUtils.configureRecyclerViewWithInfiniteList(discussionResponsesRecyclerView, courseDiscussionResponsesAdapter, responsesLoader);
discussionResponsesRecyclerView.setAdapter(courseDiscussionResponsesAdapter);
responsesLoader.freeze();
if (getAndReadThreadCall != null) {
getAndReadThreadCall.cancel();
}
final TaskMessageCallback mCallback = activity instanceof TaskMessageCallback ? (TaskMessageCallback) activity : null;
getAndReadThreadCall = discussionService.setThreadRead(discussionThread.getIdentifier(), new ReadBody(true));
// Setting a thread's "read" state gives us back the updated Thread object.
getAndReadThreadCall.enqueue(new ErrorHandlingCallback<DiscussionThread>(activity, null, mCallback, CallTrigger.LOADING_UNCACHED) {
@Override
protected void onResponse(@NonNull final DiscussionThread discussionThread) {
courseDiscussionResponsesAdapter.updateDiscussionThread(discussionThread);
responsesLoader.unfreeze();
EventBus.getDefault().post(new DiscussionThreadUpdatedEvent(discussionThread));
}
});
DiscussionUtils.setStateOnTopicClosed(discussionThread.isClosed(), addResponseTextView, R.string.discussion_responses_add_response_button, R.string.discussion_add_response_disabled_title, addResponseLayout, new View.OnClickListener() {
@Override
public void onClick(View v) {
router.showCourseDiscussionAddResponse(activity, discussionThread);
}
});
addResponseLayout.setEnabled(!courseData.isDiscussionBlackedOut());
}
Aggregations