Search in sources :

Example 6 with DiscussionThread

use of org.edx.mobile.discussion.DiscussionThread in project edx-app-android by edx.

the class CourseDiscussionResponsesAdapter method bindSocialView.

private void bindSocialView(DiscussionSocialLayoutViewHolder holder, DiscussionThread thread) {
    holder.setDiscussionThread(thread);
    holder.voteViewContainer.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            discussionService.setThreadVoted(discussionThread.getIdentifier(), new VoteBody(!discussionThread.isVoted())).enqueue(new ErrorHandlingCallback<DiscussionThread>(context, null, new DialogErrorNotification(baseFragment)) {

                @Override
                protected void onResponse(@NonNull final DiscussionThread updatedDiscussionThread) {
                    discussionThread = discussionThread.patchObject(updatedDiscussionThread);
                    notifyItemChanged(0);
                    EventBus.getDefault().post(new DiscussionThreadUpdatedEvent(discussionThread));
                }
            });
        }
    });
    holder.threadFollowContainer.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            discussionService.setThreadFollowed(discussionThread.getIdentifier(), new FollowBody(!discussionThread.isFollowing())).enqueue(new ErrorHandlingCallback<DiscussionThread>(context, null, new DialogErrorNotification(baseFragment)) {

                @Override
                protected void onResponse(@NonNull final DiscussionThread updatedDiscussionThread) {
                    discussionThread = discussionThread.patchObject(updatedDiscussionThread);
                    notifyItemChanged(0);
                    EventBus.getDefault().post(new DiscussionThreadUpdatedEvent(discussionThread));
                }
            });
        }
    });
}
Also used : ErrorHandlingCallback(org.edx.mobile.http.callback.ErrorHandlingCallback) FollowBody(org.edx.mobile.discussion.DiscussionService.FollowBody) VoteBody(org.edx.mobile.discussion.DiscussionService.VoteBody) NonNull(android.support.annotation.NonNull) DialogErrorNotification(org.edx.mobile.http.notifications.DialogErrorNotification) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) DiscussionThread(org.edx.mobile.discussion.DiscussionThread) DiscussionThreadUpdatedEvent(org.edx.mobile.discussion.DiscussionThreadUpdatedEvent)

Aggregations

DiscussionThread (org.edx.mobile.discussion.DiscussionThread)6 Activity (android.app.Activity)3 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 TextView (android.widget.TextView)3 DiscussionThreadUpdatedEvent (org.edx.mobile.discussion.DiscussionThreadUpdatedEvent)3 NonNull (android.support.annotation.NonNull)2 ErrorHandlingCallback (org.edx.mobile.http.callback.ErrorHandlingCallback)2 DialogErrorNotification (org.edx.mobile.http.notifications.DialogErrorNotification)2 Page (org.edx.mobile.model.Page)2 TaskMessageCallback (org.edx.mobile.view.common.TaskMessageCallback)2 BaseFragmentActivity (org.edx.mobile.base.BaseFragmentActivity)1 FlagBody (org.edx.mobile.discussion.DiscussionService.FlagBody)1 FollowBody (org.edx.mobile.discussion.DiscussionService.FollowBody)1 ReadBody (org.edx.mobile.discussion.DiscussionService.ReadBody)1 VoteBody (org.edx.mobile.discussion.DiscussionService.VoteBody)1 CourseDiscussionResponsesAdapter (org.edx.mobile.view.adapters.CourseDiscussionResponsesAdapter)1 TaskProcessCallback (org.edx.mobile.view.common.TaskProcessCallback)1 TaskProgressCallback (org.edx.mobile.view.common.TaskProgressCallback)1 ProgressViewController (org.edx.mobile.view.common.TaskProgressCallback.ProgressViewController)1