use of org.edx.mobile.discussion.DiscussionService.ReadBody 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