use of org.edx.mobile.discussion.CourseTopics in project edx-app-android by edx.
the class CourseDiscussionPostsThreadFragment method fetchDiscussionTopic.
private void fetchDiscussionTopic() {
String topicId = getArguments().getString(Router.EXTRA_DISCUSSION_TOPIC_ID);
final Activity activity = getActivity();
discussionService.getSpecificCourseTopics(courseData.getCourse().getId(), Collections.singletonList(topicId)).enqueue(new ErrorHandlingCallback<CourseTopics>(activity, new ProgressViewController(loadingIndicator), errorNotification) {
@Override
protected void onResponse(@NonNull final CourseTopics courseTopics) {
discussionTopic = courseTopics.getCoursewareTopics().get(0).getChildren().get(0);
if (activity != null && !getArguments().getBoolean(ARG_DISCUSSION_HAS_TOPIC_NAME)) {
// We only need to set the title here when coming from a deep link
activity.setTitle(discussionTopic.getName());
}
if (getView() != null) {
if (populatePostListRunnable != null) {
populatePostListRunnable.run();
}
// Now that we have the topic data, we can allow the user to add new posts.
setCreateNewPostBtnVisibility(View.VISIBLE);
}
}
});
}
use of org.edx.mobile.discussion.CourseTopics in project edx-app-android by edx.
the class DiscussionAddPostFragment method getTopicList.
protected void getTopicList() {
if (getTopicListCall != null) {
getTopicListCall.cancel();
}
getTopicListCall = discussionService.getCourseTopics(courseData.getCourse().getId());
getTopicListCall.enqueue(new ErrorHandlingCallback<CourseTopics>(getActivity(), null, null, CallTrigger.LOADING_CACHED) {
@Override
protected void onResponse(@NonNull final CourseTopics courseTopics) {
final ArrayList<DiscussionTopic> allTopics = new ArrayList<>();
allTopics.addAll(courseTopics.getNonCoursewareTopics());
allTopics.addAll(courseTopics.getCoursewareTopics());
final TopicSpinnerAdapter adapter = new TopicSpinnerAdapter(container.getContext(), DiscussionTopicDepth.createFromDiscussionTopics(allTopics));
topicsSpinner.setAdapter(adapter);
{
// Otherwise, leave the default option, which is the first non-courseware topic
if (!discussionTopic.isAllType() && !discussionTopic.isFollowingType()) {
int selectedTopicIndex = -1;
if (discussionTopic.getIdentifier() == null) {
// In case of a parent topic, we need to select the first child topic
if (!discussionTopic.getChildren().isEmpty()) {
selectedTopicIndex = adapter.getPosition(discussionTopic.getChildren().get(0));
}
} else {
selectedTopicIndex = adapter.getPosition(discussionTopic);
}
if (selectedTopicIndex >= 0) {
topicsSpinner.setSelection(selectedTopicIndex);
}
}
}
DiscussionTopic selectedTopic = ((DiscussionTopicDepth) topicsSpinner.getSelectedItem()).getDiscussionTopic();
Map<String, String> values = new HashMap<>();
values.put(Analytics.Keys.TOPIC_ID, selectedTopic.getIdentifier());
analyticsRegistry.trackScreenView(Analytics.Screens.FORUM_CREATE_TOPIC_THREAD, courseData.getCourse().getId(), selectedTopic.getName(), values);
}
});
}
Aggregations